예제 #1
0
        public VideoParam AdjustVideoParam(VideoAdjusterParam videoAdjusterParam, string mediaContainer, IVideoSize videoSize)
        {
            var exceptionList = new List <VideoFormatException>();
            int size          = videoSize.Square();

            string container    = AdjustMediaContainer(videoAdjusterParam.MediaContainer, mediaContainer, exceptionList);
            string videoCodec   = AdjustVideoCodec(mediaContainer, videoAdjusterParam.VideoCodec, exceptionList);
            int    videoBitrate = AdjustVideoBitrate(videoAdjusterParam.VideoBitrate, size, exceptionList);
            int    videoWidth   = AdjustVideoWidth(videoSize.Width, exceptionList);
            int    videoHeight  = AdjustVideoHeight(videoSize.Height, exceptionList);
            double frameRate    = AdjustFrameRate(videoAdjusterParam.FrameRate, videoAdjusterParam.FrameRateMode, exceptionList);

            IVideoSize videoRotateSize = _adjustmentVideoMetadata.AdjustVideoRotateSize(videoWidth, videoHeight, videoAdjusterParam.VideoRotation);
            string     videoProfile    = _adjustmentVideoMetadata.AdjustVideoProfile(mediaContainer, videoAdjusterParam.VideoProfile);
            int        keyFrameRate    = _adjustmentVideoMetadata.AdjustKeyFrameRate(videoAdjusterParam.KeyFrameRate);

            CheckForException(exceptionList);

            VideoParam adjustVideoParam = CreateParam(container,
                                                      videoCodec,
                                                      videoProfile,
                                                      videoBitrate,
                                                      videoRotateSize.Width,
                                                      videoRotateSize.Height,
                                                      frameRate,
                                                      keyFrameRate,
                                                      videoAdjusterParam.VideoRotation);

            return(adjustVideoParam);
        }
예제 #2
0
 public bool VideoParamCompare(VideoAdjusterParam videoAdjusterParam, VideoParam videoParam, string newContainer, IVideoSize videoSize)
 {
     return(videoAdjusterParam.VideoCodec == videoParam.VideoCodec &&
            ((newContainer == MetadataConstant.Mp4Container && videoAdjusterParam.VideoProfile == videoParam.VideoProfile) || (MetadataConstant.Mp4Container != newContainer)) &&
            videoAdjusterParam.VideoBitrate == videoParam.VideoBitrate &&
            videoSize.Width == videoParam.VideoWidth &&
            videoSize.Height == videoParam.VideoHeight &&
            videoAdjusterParam.FrameRate == videoParam.FrameRate &&
            videoAdjusterParam.KeyFrameRate == videoParam.KeyFrameRate);
 }
        public DomainProcessedVideo BuildProcessedVideo(VideoAdjusterParam videoAdjusterParam, AudioAdjusterParam audioAdjusterParam, string newContainer, IVideoSize videoSize, string contentType)
        {
            VideoParam           videoParam     = _videoAdjuster.AdjustVideoParam(videoAdjusterParam, newContainer, videoSize);
            AudioParam           audioParam     = _audioAdjuster.AdjustAudioParam(audioAdjusterParam, newContainer, videoSize);
            bool                 isVideoCopy    = _comparator.VideoParamCompare(videoAdjusterParam, videoParam, newContainer, videoSize);
            bool                 isAudioCopy    = _comparator.AudioParamCompare(audioAdjusterParam, audioParam);
            DomainProcessedVideo processedVideo = CreateProcessedVideo(videoParam, audioParam, isVideoCopy, isAudioCopy, contentType);

            return(processedVideo);
        }
예제 #4
0
        public void Initialize()
        {
            const string mediaContainer = "mediaContainer";
            const string videoCodec     = "videoCodec";
            const string videoProfile   = "videoProfile";
            const int    videoBitrate   = 10000;
            const int    width          = 150;
            const int    height         = 100;
            const double frameRate      = 25;
            const int    keyFrameRate   = 10;

            const string audioCodec   = "audioCodec";
            const int    audioBitrate = 500;

            _comparator = new Comparator();

            _videoSize = new VideoSize(width, height);

            _videoAdjusterParam = new VideoAdjusterParam()
            {
                MediaContainer = mediaContainer,
                VideoCodec     = videoCodec,
                VideoProfile   = videoProfile,
                VideoBitrate   = videoBitrate,
                FrameRate      = frameRate,
                KeyFrameRate   = keyFrameRate
            };

            _videoParam = new VideoParam()
            {
                MediaContainer = mediaContainer,
                VideoCodec     = videoCodec,
                VideoProfile   = videoProfile,
                VideoBitrate   = videoBitrate,
                VideoWidth     = width,
                VideoHeight    = height,
                FrameRate      = frameRate,
                KeyFrameRate   = keyFrameRate
            };

            _audioAdjusterParam = new AudioAdjusterParam()
            {
                AudioCodec   = audioCodec,
                AudioBitrate = audioBitrate
            };

            _audioParam = new AudioParam()
            {
                AudioCodec   = audioCodec,
                AudioBitrate = audioBitrate
            };
        }
 private DomainProcessedVideo CreateProcessedVideo(VideoParam videoParam, AudioParam audioParam, bool isVideoCopy, bool isAudioCopy, string contentType)
 {
     return(new DomainProcessedVideo
     {
         VideoParam = videoParam,
         AudioParam = audioParam,
         IsVideoCopy = isVideoCopy,
         IsAudioCopy = isAudioCopy,
         OutputFormat = String.Format("{0}x{1}", videoParam.MediaContainer, videoParam.VideoWidth),
         ContentType = contentType,
         Created = DateTime.UtcNow,
         Modified = DateTime.UtcNow,
         Started = DateTime.UtcNow,
         Completed = DateTime.UtcNow
     });
 }
    void Start()
    {
        _profile = Camera.main.GetComponent <PostProcessingBehaviour>().profile;

        if (File.Exists(Application.persistentDataPath + "/videoSettings.dat"))
        {
            BinaryFormatter bf   = new BinaryFormatter();
            FileStream      file = File.Open(Application.persistentDataPath + "/videoSettings.dat", FileMode.Open);
            _params = (VideoParam)bf.Deserialize(file);

            file.Close();

            AAToggle.isOn   = _params.AAenabled;
            AAQuality.value = _params.AApreset;
            MBToggle.isOn   = _params.MBenabled;
            AOToggle.isOn   = _params.AOenabled;
        }
    }
예제 #7
0
        public Operation AddWatchedVideoPoint(VideoParam model)
        {
            return(Operation.Create(() =>
            {
                if (model == null)
                {
                    throw new Exception("Video param cannot be empty");
                }

                userPoint.AddUserPointOrUpdate(new UserPointModel()
                {
                    Channel = model.Channel,
                    Point = model.Point,
                    UserId = model.UserId,
                });

                return;
            }));
        }
        public void BuildProcessedVideoTest()
        {
            //Arrange
            const string newContainer       = "newContainer";
            const string contentType        = "contentType";
            const bool   isVideoParamEquals = true;
            const bool   isAudioParamEquals = false;
            const int    videoWidth         = 2134;

            var videoAdjusterParam = new VideoAdjusterParam();
            var audioAdjusterParam = new AudioAdjusterParam();

            var videoParam = new VideoParam()
            {
                VideoWidth = videoWidth, MediaContainer = newContainer
            };
            var audioParam   = new AudioParam();
            var outputFormat = string.Format("{0}x{1}", videoParam.MediaContainer, videoParam.VideoWidth);

            var videoSize          = new Mock <IVideoSize>();
            var videoParamAdjuster = new Mock <IVideoAdjuster>();
            var audioParamAdjuster = new Mock <IAudioAdjuster>();
            var comparator         = new Mock <IComparator>();

            videoParamAdjuster.Setup(m => m.AdjustVideoParam(videoAdjusterParam, newContainer, videoSize.Object)).Returns(videoParam);
            audioParamAdjuster.Setup(m => m.AdjustAudioParam(audioAdjusterParam, newContainer, videoSize.Object)).Returns(audioParam);
            comparator.Setup(m => m.VideoParamCompare(videoAdjusterParam, videoParam, newContainer, videoSize.Object)).Returns(isVideoParamEquals);
            comparator.Setup(m => m.AudioParamCompare(audioAdjusterParam, audioParam)).Returns(isAudioParamEquals);

            var builder = new ProcessedVideoBuilder(videoParamAdjuster.Object, audioParamAdjuster.Object, comparator.Object);

            //Act
            var processedVideo = builder.BuildProcessedVideo(videoAdjusterParam, audioAdjusterParam, newContainer, videoSize.Object, contentType);

            //Assert
            Assert.AreEqual(videoParam, processedVideo.VideoParam);
            Assert.AreEqual(audioParam, processedVideo.AudioParam);
            Assert.AreEqual(isVideoParamEquals, processedVideo.IsVideoCopy);
            Assert.AreEqual(isAudioParamEquals, processedVideo.IsAudioCopy);
            Assert.AreEqual(outputFormat, processedVideo.OutputFormat);
            Assert.AreEqual(contentType, processedVideo.ContentType);
        }
        public async Task <PagedList <Video> > GetVideos(VideoParam videoParams, int courseId)
        {
            var videoFromRepo = _context.Videos.Where(v => v.CourseId == courseId);

            return(await PagedList <Video> .CreateAsync(videoFromRepo, videoParams.PageNumber, videoParams.PageSize));
        }
예제 #10
0
        public IActionResult AddPointToVideoWatched([FromBody] VideoParam model)
        {
            var op = _service.AddWatchedVideoPoint(model);

            return(Ok(op));
        }