Beispiel #1
0
        private VideoSize ParseVideoSize(string value)
        {
            VideoSize result = VideoSize.NotSpecified;

            if (!string.IsNullOrEmpty(value))
            {
                string sizeValue = value.Trim();
                if (sizeValue.Equals(VideoSize.Small.ToString(), StringComparison.InvariantCultureIgnoreCase))
                {
                    result = VideoSize.Small;
                }
                else if (sizeValue.Equals(VideoSize.Medium.ToString(), StringComparison.InvariantCultureIgnoreCase))
                {
                    result = VideoSize.Medium;
                }
                else if (sizeValue.Equals(VideoSize.Large.ToString(), StringComparison.InvariantCultureIgnoreCase))
                {
                    result = VideoSize.Large;
                }
                else
                {
                    result = VideoSize.NotSpecified;
                }
            }
            return(result);
        }
        private void engine_InitSize(object sender, InitSizeEventArgs e)
        {
            VideoSize size = mediaControl.VideoSize;
            int       div  = 1;

            if (size == VideoSize.SIZE50)
            {
                size = VideoSize.SIZE100;
                div  = 2;
            }
            if (WindowState != FormWindowState.Maximized && !bFullscreen &&
                size != VideoSize.SIZE_FREE && e.NewVideSize.Height != 0 && e.NewVideSize.Width != 0)
            {
                Rectangle bounds = DesktopBounds;
                Size      client = mediaControl.ClientSize;

                int nSize = (int)size;
                int hor   = ((int)(e.NewVideSize.Width * nSize / div)) - client.Width;
                int vert  = ((int)(e.NewVideSize.Height * nSize / div)) - client.Height;

                bounds.Width  += hor;
                bounds.Height += vert;

                if (bCenterWindow)
                {
                    Rectangle rect = Screen.FromControl(this).WorkingArea;
                    bounds.X = bounds.Width < rect.Width ? rect.X + (rect.Width - bounds.Width) / 2 : rect.X;
                    bounds.Y = bounds.Height < rect.Height ? rect.Y + (rect.Height - bounds.Height) / 2 : rect.Y;
                }

                DesktopBounds = bounds;
            }
        }
Beispiel #3
0
        public void Equals_NotSameType_ReturnFalse()
        {
            var size  = new VideoSize(1, 2);
            var check = new object();

            Assert.False(size.Equals(check));
        }
Beispiel #4
0
        public void EqualOperator_NotEqual_ReturnFalse()
        {
            var size1 = new VideoSize(1, 2);
            var size2 = new VideoSize(2, 2);

            Assert.False(size1 == size2);
        }
Beispiel #5
0
        public void Equals_NotEqual_ReturnFalse()
        {
            var size1 = new VideoSize(1, 2);
            var size2 = new VideoSize(2, 2);

            Assert.False(size1.Equals(size2));
        }
Beispiel #6
0
        private static string GetSize(VideoSize videoSize, int width, int height)
        {
            switch (videoSize)
            {
            case VideoSize.F360p:
            {
                Tuple <int, int> finalSize = SizeHelper.GetSize(width, height, 640, 360);
                return($"{finalSize.Item1}:{finalSize.Item2}");
            }

            case VideoSize.F480p:
            {
                Tuple <int, int> finalSize = SizeHelper.GetSize(width, height, 854, 480);
                return($"{finalSize.Item1}:{finalSize.Item2}");
            }

            case VideoSize.F720p:
            {
                Tuple <int, int> finalSize = SizeHelper.GetSize(width, height, 1280, 720);
                return($"{finalSize.Item1}:{finalSize.Item2}");
            }

            case VideoSize.F1080p:
            {
                Tuple <int, int> finalSize = SizeHelper.GetSize(width, height, 1920, 1080);
                return($"{finalSize.Item1}:{finalSize.Item2}");
            }

            default:
                throw new InvalidOperationException("Format non reconnu.");
            }
        }
Beispiel #7
0
        public void Parse_ValidArgs_Equality()
        {
            var size = VideoSize.Parse("1x2");

            Assert.AreEqual(1, size.Width);
            Assert.AreEqual(2, size.Height);
        }
Beispiel #8
0
 /// <summary>
 /// Initializes a video stream of optimal settings.
 /// </summary>
 /// <param name="xbox"></param>
 public XboxVideoStream(Xbox xbox)
 {
     Xbox      = xbox;
     this.size = VideoSize.Medium;
     Quality   = VideoQuality.Regular;
     Interval  = VideoPresentationInterval.Two;
 }
        public ScreenRecordForm( IPluginHost pluginHost )
            : base(pluginHost)
        {
            this.StickyWindow = new DroidExplorer.UI.StickyWindow ( this );
            CommonResolutions = GetCommonResolutions ( );
            InitializeComponent ( );

            var defaultFile = "screenrecord_{0}_{1}.mp4".With ( this.PluginHost.Device, DateTime.Now.ToString ( "yyyy-MM-dd-hh" ) );
            this.location.Text = "/sdcard/{0}".With ( defaultFile );

            var resolution = new VideoSize ( PluginHost.CommandRunner.GetScreenResolution ( ) );
            var sizes = CommonResolutions.Concat ( new List<VideoSize> { resolution } ).OrderBy ( x => x.Size.Width ).Select ( x => x ).ToList ( );
            resolutionList.DataSource = sizes;
            resolutionList.DisplayMember = "Display";
            resolutionList.ValueMember = "Size";
            resolutionList.SelectedItem = resolution;

            rotateList.DataSource = GetRotateArgumentsList ( );
            rotateList.DisplayMember = "Display";
            rotateList.ValueMember = "Arguments";

            var bitrates = new List<BitRate> ( );

            for ( int i = 1; i < 25; i++ ) {
                bitrates.Add ( new BitRate ( i ) );
            }

            bitrateList.DataSource = bitrates;
            bitrateList.DisplayMember = "Display";
            bitrateList.ValueMember = "Value";
            bitrateList.SelectedItem = bitrates.Single ( x => x.Mbps == 4 );
            var ts = new TimeSpan ( 0, 0, 0, timeLimit.Value, 0 );
            displayTime.Text = ts.ToString ( );
        }
Beispiel #10
0
 /// <summary>
 ///     Change video size
 /// </summary>
 /// <param name="inputPath">Input path</param>
 /// <param name="output">Output path</param>
 /// <param name="size">Expected size</param>
 /// <returns>Conversion result</returns>
 public static IConversion ChangeSize(string inputPath, string output, VideoSize size)
 {
     return(new Conversion()
            .SetInput(inputPath)
            .SetScale(size)
            .SetOutput(output));
 }
Beispiel #11
0
        void FullscreenOn()
        {
            nicon.Restore();
            bFullscreen = true;

            bControlbar           = controlbar.Visible;
            nControlbarChildIndex = Controls.GetChildIndex(controlbar);
            controlbar.Parent     = controlbarHolder;
            controlbar.Visible    = true;

            CaptionBar.Visible = false;
            Border             = false;
            TopMost            = true;

            nVideoSize             = mediaControl.VideoSize;
            mediaControl.VideoSize = VideoSize.SIZE_FREE;

            Rectangle rect = Screen.FromControl(this).Bounds;

            MaximumSize     = rect.Size;
            formWindowState = WindowState;
            WindowState     = FormWindowState.Normal;

            Bounds = rect;

            controlbarHolder.StartPosition = FormStartPosition.Manual;
            controlbarHolder.Bounds        = new Rectangle(rect.Left, rect.Bottom - controlbar.Height,
                                                           rect.Width, controlbar.Height);
            controlbarHolder.TopMost = true;

            //	Activate(); // We will handle KeyDown and MouseWheel of the controlbarHolder
            // in MainFormControls so we don't need to activate ourselves
        }
Beispiel #12
0
        public void EqualOperator_SameRef_ReturnTrue()
        {
            var size = new VideoSize(1, 2);

#pragma warning disable CS1718 // Comparison made to same variable
            Assert.True(size == size);
#pragma warning restore CS1718 // Comparison made to same variable
        }
Beispiel #13
0
 /// <inheritdoc />
 public IVideoStream SetScale(VideoSize size)
 {
     if (size != null)
     {
         _scale = $"-vf scale={size} ";
     }
     return(this);
 }
Beispiel #14
0
 /// <inheritdoc />
 public IVideoStream SetSize(VideoSize size)
 {
     if (size != null)
     {
         _size = $"-s {size} ";
     }
     return(this);
 }
Beispiel #15
0
 /// <inheritdoc />
 public IConversion SetScale(VideoSize size)
 {
     if (!string.IsNullOrWhiteSpace(size?.Resolution))
     {
         _scale = $"-vf scale={size.Resolution} ";
     }
     return(this);
 }
        /// <summary>
        ///     Convert video file with implicit output. Output will be in the parent directory of the original video file.
        /// </summary>
        /// <param name="type">Output format.</param>
        /// <param name="speed">MP4 encoding speed (applies only to mp4 format). Faster results in lower quality.</param>
        /// <param name="size">Aspect ratio of the output video file.</param>
        /// <param name="audio">Audio quality of the output video file.</param>
        /// <param name="multithread">Tell FFMpeg to use multithread in the conversion process.</param>
        /// <param name="deleteOriginal">
        ///     Flag original file purging after conversion is done (Will not result in exception if file is
        ///     readonly or missing.).
        /// </param>
        /// <returns>Video information object with the new video file.</returns>
        public VideoInfo ConvertTo(VideoType type, Speed speed = Speed.SuperFast, VideoSize size       = VideoSize.Original,
                                   AudioQuality audio          = AudioQuality.Normal, bool multithread = false, bool deleteOriginal = false)
        {
            var outputPath = FullName.Replace(Extension, $".{type.ToString().ToLower()}");
            var output     = new FileInfo(outputPath);

            return(ConvertTo(type, output, speed, size, audio, multithread, deleteOriginal));
        }
Beispiel #17
0
 public VideoClip GetForSize(VideoSize size)
 {
     switch (size)
     {
     case VideoSize.Video480:
     default:
         return(video480);
     }
 }
Beispiel #18
0
        public static void RaiseResizeMainWindowEvent(this VideoSize size, Tuple <double, double> videoSize, bool centerWindow)
        {
            var resizeMessage = size == VideoSize.SIZE_FREE ?
                                new ResizeMainWindowCommandMessage(Command.ResizeMainWindow, centerWindow)
                        :
                                new ResizeMainWindowCommandMessage(Command.ResizeMainWindow, videoSize, size.GetResizeCoefficient(), centerWindow);

            Messenger.Default.Send(resizeMessage);
        }
 public static Vector2Int GetResolution(this VideoSize size)
 {
     switch (size)
     {
     case VideoSize.Video480:
     default:
         return(new Vector2Int(270, 480));
     }
 }
Beispiel #20
0
        /// <summary>
        /// Convert a video do a different format.
        /// </summary>
        /// <param name="source">Input video source.</param>
        /// <param name="output">Output information.</param>
        /// <param name="type">Target conversion video type.</param>
        /// <param name="speed">Conversion target speed/quality (faster speed = lower quality).</param>
        /// <param name="size">Video size.</param>
        /// <param name="audioQuality">Conversion target audio quality.</param>
        /// <param name="multithreaded">Is encoding multithreaded.</param>
        /// <returns>Output video information.</returns>
        public VideoInfo Convert(
            VideoInfo source,
            FileInfo output,
            VideoType type = VideoType.Mp4,
            Speed speed    =
            Speed.SuperFast,
            VideoSize size =
            VideoSize.Original,
            AudioQuality audioQuality = AudioQuality.Normal,
            bool multithreaded        = false)
        {
            FFMpegHelper.ConversionExceptionCheck(source.ToFileInfo(), output);
            FFMpegHelper.ExtensionExceptionCheck(output, FileExtension.ForType(type));
            FFMpegHelper.ConversionSizeExceptionCheck(source);

            string args = "";

            var height = source.Height * (source.Width / (int)size);

            switch (type)
            {
            case VideoType.Mp4:
                args = Arguments.Input(source) +
                       Arguments.Threads(multithreaded) +
                       Arguments.Scale(size, height) +
                       Arguments.Video(VideoCodec.LibX264, 2400) +
                       Arguments.Speed(speed) +
                       Arguments.Audio(AudioCodec.Aac, audioQuality) +
                       Arguments.Output(output);
                break;

            case VideoType.Ogv:
                args = Arguments.Input(source) +
                       Arguments.Threads(multithreaded) +
                       Arguments.Scale(size, height) +
                       Arguments.Video(VideoCodec.LibTheora, 2400) +
                       Arguments.Speed(16) +
                       Arguments.Audio(AudioCodec.LibVorbis, audioQuality) +
                       Arguments.Output(output);
                break;

            case VideoType.Ts:
                args = Arguments.Input(source) +
                       Arguments.Copy() +
                       Arguments.BitStreamFilter(Channel.Video, Filter.H264_Mp4ToAnnexB) +
                       Arguments.ForceFormat(VideoCodec.MpegTs) +
                       Arguments.Output(output);
                break;
            }

            if (!RunProcess(args, output))
            {
                throw new FFMpegException(FFMpegExceptionType.Conversion, $"The video could not be converted to {Enum.GetName(typeof(VideoType), type)}");
            }

            return(new VideoInfo(output));
        }
 public static IConversion ToWebM(string inputPath, string outputPath, VideoSize size = null, AudioQuality audioQuality = AudioQuality.Normal)
 {
     return(new Conversion()
            .SetInput(inputPath)
            .SetScale(size)
            .SetVideo(VideoCodec.LibVpx, 2400)
            .SetSpeed(16)
            .SetAudio(AudioCodec.LibVorbis, audioQuality)
            .SetOutput(outputPath));
 }
Beispiel #22
0
 /// <summary>
 ///     Convert file to OGV
 /// </summary>
 /// <param name="inputPath">Input path</param>
 /// <param name="outputPath">Destination file</param>
 /// <param name="size">Dimension</param>
 /// <param name="audioQuality">Audio quality</param>
 /// <param name="multithread">Use multithread</param>
 /// <returns>Conversion result</returns>
 public static IConversion ToOgv(string inputPath, string outputPath, VideoSize size = null, AudioQuality audioQuality = AudioQuality.Normal, bool multithread = false)
 {
     return(new Conversion()
            .SetInput(inputPath)
            .SetScale(size)
            .SetVideo(VideoCodec.LibTheora, 2400)
            .SetAudio(AudioCodec.LibVorbis, audioQuality)
            .SetOutput(outputPath)
            .UseMultiThread(multithread));
 }
Beispiel #23
0
        /// <summary>
        /// Convert a video do a different format.
        /// </summary>
        /// <param name="source">Input video source.</param>
        /// <param name="output">Output information.</param>
        /// <param name="type">Target conversion video type.</param>
        /// <param name="speed">Conversion target speed/quality (faster speed = lower quality).</param>
        /// <param name="size">Video size.</param>
        /// <param name="audioQuality">Conversion target audio quality.</param>
        /// <param name="multithreaded">Is encoding multithreaded.</param>
        /// <returns>Output video information.</returns>
        public VideoInfo Convert(
            VideoInfo source,
            FileInfo output,
            VideoType type            = VideoType.Mp4,
            Speed speed               = Speed.SuperFast,
            VideoSize size            = VideoSize.Original,
            AudioQuality audioQuality = AudioQuality.Normal,
            bool multithreaded        = false)
        {
            FFMpegHelper.ConversionExceptionCheck(source.ToFileInfo(), output);
            FFMpegHelper.ExtensionExceptionCheck(output, FileExtension.ForType(type));
            FFMpegHelper.ConversionSizeExceptionCheck(source);

            var scale      = VideoSize.Original == size ? 1 : (double)source.Height / (int)size;
            var outputSize = new Size((int)(source.Width / scale), (int)(source.Height / scale));

            if (outputSize.Width % 2 != 0)
            {
                outputSize.Width += 1;
            }

            return(type switch
            {
                VideoType.Mp4 => Convert(new ArgumentContainer(
                                             new InputArgument(source),
                                             new ThreadsArgument(multithreaded),
                                             new ScaleArgument(outputSize),
                                             new VideoCodecArgument(VideoCodec.LibX264, 2400),
                                             new SpeedArgument(speed),
                                             new AudioCodecArgument(AudioCodec.Aac, audioQuality),
                                             new OutputArgument(output))),
                VideoType.Ogv => Convert(new ArgumentContainer(
                                             new InputArgument(source),
                                             new ThreadsArgument(multithreaded),
                                             new ScaleArgument(outputSize),
                                             new VideoCodecArgument(VideoCodec.LibTheora, 2400),
                                             new SpeedArgument(speed),
                                             new AudioCodecArgument(AudioCodec.LibVorbis, audioQuality),
                                             new OutputArgument(output))),
                VideoType.Ts => Convert(new ArgumentContainer(
                                            new InputArgument(source),
                                            new CopyArgument(),
                                            new BitStreamFilterArgument(Channel.Video, Filter.H264_Mp4ToAnnexB),
                                            new ForceFormatArgument(VideoCodec.MpegTs),
                                            new OutputArgument(output))),
                VideoType.WebM => Convert(new ArgumentContainer(
                                              new InputArgument(source),
                                              new ThreadsArgument(multithreaded),
                                              new ScaleArgument(outputSize),
                                              new VideoCodecArgument(VideoCodec.LibVpx, 2400),
                                              new SpeedArgument(speed),
                                              new AudioCodecArgument(AudioCodec.LibVorbis, audioQuality),
                                              new OutputArgument(output))),
                _ => throw new ArgumentOutOfRangeException(nameof(type))
            });
Beispiel #24
0
 public void LoadRelatedVideoContent(string videoSourceUrl, VideoSize videoSize)
 {
     if (HasRelatedContentPanel)
     {
         if (RelatedContentController != null)
         {
             string sizeValue = videoSize.ToString().ToLower();
             RelatedContentController.Invoke("loadRelatedContent", "video", HttpUtility.UrlEncode(videoSourceUrl), sizeValue);
         }
     }
 }
Beispiel #25
0
        public static Guid ComputeVideo(string originFilePath, string videoEncodingFormats, bool?sprite)
        {
            VideoSize[] formats = new VideoSize[0];

            if (!string.IsNullOrWhiteSpace(videoEncodingFormats))
            {
                formats = videoEncodingFormats
                          .Split(',')
                          .Select(v =>
                {
                    switch (v)
                    {
                    case "360p":
                        return(VideoSize.F360p);

                    case "480p":
                        return(VideoSize.F480p);

                    case "720p":
                        return(VideoSize.F720p);

                    case "1080p":
                        return(VideoSize.F1080p);

                    default:
                        throw new InvalidOperationException("Format non reconnu.");
                    }
                })
                          .ToArray();
            }

            FileContainer fileContainer = FileContainer.NewVideoContainer(originFilePath, sprite ?? false, formats);

            if (IpfsSettings.AddVideoSource)
            {
                IpfsDaemon.Instance.Queue(fileContainer.SourceFileItem);
            }

            if (VideoSettings.GpuEncodeMode)
            {
                // encoding audio de la source puis ça sera encoding videos Gpu
                AudioCpuEncodeDaemon.Instance.Queue(fileContainer.SourceFileItem, "waiting audio encoding...");
            }
            else
            {
                // si encoding est demandé, et gpuMode -> encodingAudio
                foreach (FileItem file in fileContainer.EncodedFileItems)
                {
                    AudioVideoCpuEncodeDaemon.Instance.Queue(file, "Waiting encode...");
                }
            }

            return(fileContainer.ProgressToken);
        }
Beispiel #26
0
        /// <summary>
        /// 初始化音视频通信组件
        /// </summary>
        /// <param name="Model">视频显示大小模式</param>
        public void iniAV(VideoSizeModel Model, System.Net.IPEndPoint ServerEP)
        {
            if (!IsIni)
            {
                IsIni = true;//标识已经初始化
            }
            else
            {
                return;                //如果已经初始化,则退出
            }
            VideoSize.SetModel(Model); //设置视频编码尺寸

            if (cam == null)
            {
                iniVideoCapturer();
            }

            #region //创建新的视频捕捉组件
            //if (VC == null)
            //{
            //    VC = new  VideoCapturer(this.cLocal);
            //    VC.VideoCapturerBefore += new VideoCapturer.VideoCaptureredEventHandler(VC_VideoCapturerBefore);
            //    VC.VideoDataCapturered += new VideoCapturer.VideoCaptureredEventHandler(VC_VideoDataCapturered);
            //    VC.StartVideoCapture(Model);//开始捕捉视频
            //}
            #endregion

            if (AE == null)
            {
                AE = new AudioEncoder();//创建G711音频编解码器
            }

            if (AC == null)
            {
                AC = new AudioCapturer(this.trackBarOut, this.trackBarIn);//创建新的音频捕捉组件
                AC.AudioDataCapturered += new AudioCapturer.AudioDataCaptureredEventHandler(AC_AudioDataCapturered);
            }

            if (AR == null)
            {
                AR = new AudioRender();//创建G711音频回放组件
            }

            if (frameTransmit == null)
            {
                frameTransmit = new FrameTransmit(ServerEP);
                frameTransmit.GetIPEndPoint     += new FrameTransmit.GetIPEndPointEventHandler(frameTransmit_GetIPEndPoint);
                frameTransmit.RecAudioData      += new FrameTransmit.RecDataEventHandler(frameTransmit_RecAudioData);
                frameTransmit.RecVideoData      += new FrameTransmit.RecDataEventHandler(frameTransmit_RecVideoData);
                frameTransmit.TransmitConnected += new FrameTransmit.TransmitEventHandler(frameTransmit_TransmitConnected);
                frameTransmit.Start();
            }
        }
Beispiel #27
0
        public static FileItem NewEncodedVideoFileItem(FileContainer fileContainer, VideoSize videoSize)
        {
            if (videoSize == VideoSize.Undefined)
            {
                throw new InvalidOperationException("VideoSize inconnu");
            }

            FileItem fileItem = new FileItem(fileContainer, null, TypeFile.EncodedVideo);

            fileItem.VideoSize = videoSize;
            return(fileItem);
        }
Beispiel #28
0
 /// <summary>
 ///     Convert file to MP4
 /// </summary>
 /// <param name="inputPath">Input path</param>
 /// <param name="outputPath">Destination file</param>
 /// <param name="speed">Conversion speed</param>
 /// <param name="size">Dimension</param>
 /// <param name="audioQuality">Audio quality</param>
 /// <param name="multithread">Use multithread</param>
 /// <returns>Conversion result</returns>
 public static IConversion ToMp4(string inputPath, string outputPath, Speed speed = Speed.SuperFast,
                                 VideoSize size = null, AudioQuality audioQuality = AudioQuality.Normal, bool multithread = false)
 {
     return(new Conversion()
            .SetInput(inputPath)
            .UseMultiThread(multithread)
            .SetScale(size)
            .SetVideo(VideoCodec.LibX264, 2400)
            .SetSpeed(speed)
            .SetAudio(AudioCodec.Aac, audioQuality)
            .SetOutput(outputPath));
 }
Beispiel #29
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
            };
        }
Beispiel #30
0
        public static IConversion ChangeSize(string inputPath, string outputPath, VideoSize size)
        {
            IMediaInfo info = FFmpeg.GetMediaInfo(inputPath).GetAwaiter().GetResult();

            IVideoStream videoStream = info.VideoStreams.FirstOrDefault()
                                       .SetSize(size);

            return(New()
                   .AddStream(videoStream)
                   .AddStream(info.AudioStreams.ToArray())
                   .AddStream(info.SubtitleStreams.ToArray())
                   .SetOutput(outputPath));
        }
Beispiel #31
0
        /// <summary>
        ///     Change video size
        /// </summary>
        /// <param name="inputPath">Input path</param>
        /// <param name="outputPath">Output path</param>
        /// <param name="size">Expected size</param>
        /// <returns>Conversion result</returns>
        public static IConversion ChangeSize(string inputPath, string outputPath, VideoSize size)
        {
            IMediaInfo info = AsyncHelper.RunSync(() => MediaInfo.Get(inputPath));

            IVideoStream videoStream = info.VideoStreams.FirstOrDefault()
                                       .SetScale(size);

            return(New()
                   .AddStream(videoStream)
                   .AddStream(info.AudioStreams.ToArray())
                   .AddStream(info.SubtitleStreams.ToArray())
                   .SetOutput(outputPath));
        }
Beispiel #32
0
        public static string GetScale(VideoSize size)
        {
            string scale = "-vf scale=";

            switch (size)
            {
                case VideoSize.FullHD: scale += "-1:1080"; break;
                case VideoSize.HD: scale += "-1:720"; break;
                case VideoSize.ED: scale += "-1: 480"; break;
                case VideoSize.LD: scale += "-1:360"; break;
                default: scale = ""; break;
            }

            return scale;
        }
Beispiel #33
0
        public static PhotoBlock GetVideoSize(Domain.Photo photo, VideoSize size)
        {
            switch (size)
            {
                default:
                case VideoSize.Small:
                    return photo.Small;

                case VideoSize.Medium:
                    return photo.Medium;

                case VideoSize.Standard:
                    return photo.Standard;

                case VideoSize.Large:
                    return photo.Large;
            }
        }
Beispiel #34
0
        public string GetEmbededCode(VideoSize size)
        {
            int width = 0;
            int height = 0;

            switch (size)
            {
                case VideoSize.Small:
                    width = 425;
                    height = 344;
                    break;
                case VideoSize.Medium:
                    width = 480;
                    height = 385;
                    break;
                case VideoSize.Large:
                    width = 640;
                    height = 505;
                    break;
                case VideoSize.VeryLarge:
                    width = 960;
                    height = 745;
                    break;
            }

            var url = String.Format("http://www.youtube.com/v/{0}", Id);

            var sb = new StringBuilder();

            sb.AppendFormat("<object width=\"{0}\" height=\"{1}\">", width, height);
            sb.AppendFormat("<param name=\"movie\" value=\"{0}\"></param>", url);
            sb.AppendFormat("<param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param>");
            sb.AppendFormat("<embed src=\"{0}\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"{1}\" height=\"{2}\"></embed>", url, width, height);
            sb.AppendFormat("</object>");

            return sb.ToString();
        }
Beispiel #35
0
 /// <summary>
 /// Converts a source video to MP4 format.
 /// </summary>
 /// <param name="source">Source video file.</param>
 /// <param name="output">Output video file.</param>
 /// <param name="speed">Conversion speed preset.</param>
 /// <param name="size">Output video size.</param>
 /// <param name="multithread">Use multithreading for conversion.</param>
 /// <returns>Success state.</returns>
 public bool ToMP4(string source, string output, Speed speed = Speed.SuperFast, VideoSize size = VideoSize.Original, bool multithread = false)
 {
     return ToMP4(new VideoInfo(source), output, speed, size, multithread);
 }
Beispiel #36
0
        /// <summary>
        /// Converts a source video to OGV format.
        /// </summary>
        /// <param name="source">Source video file.</param>
        /// <param name="output">Output video file.</param>
        /// <param name="size">Output video size.</param>
        /// <param name="multithread">Use multithreading for conversion.</param>
        /// <returns>Success state.</returns>
        public bool ToOGV(VideoInfo source, string output, VideoSize size = VideoSize.Original, bool multithread = false)
        {
            _probe.SetVideoInfo(ref source);
            _totalVideoTime = source.Duration;
            IsConverting = true;

            string threadCount = multithread ?
                                 Environment.ProcessorCount.ToString() : "1",
                   scale = FFMpegHelper.GetScale(size);

            FFMpegHelper.ConversionExceptionCheck(source, output);
            FFMpegHelper.ExtensionExceptionCheck(output, ".ogv");

            string conversionArgs = string.Format("-i \"{0}\" -threads {1} {2} -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 \"{3}\"", source.Path,
                                                                                                                                                       threadCount,
                                                                                                                                                       scale,
                                                                                                                                                       output);
            return _RunProcess(conversionArgs);
        }
Beispiel #37
0
        /// <summary>
        /// Converts a source video to WebM format.
        /// </summary>
        /// <param name="source">Source video file.</param>
        /// <param name="output">Output video file.</param>
        /// <param name="size">Output video size.</param>
        /// <param name="multithread">Use multithreading for conversion.</param>
        /// <returns>Success state.</returns>
        public bool ToWebM(VideoInfo source, string output, VideoSize size = VideoSize.Original, bool multithread = false)
        {
            _probe.SetVideoInfo(ref source);
            _totalVideoTime = source.Duration;
            IsConverting = true;

            string threadCount = multithread ?
                                 Environment.ProcessorCount.ToString() : "1",
                   scale = FFMpegHelper.GetScale(size);

            FFMpegHelper.ConversionExceptionCheck(source, output);
            FFMpegHelper.ExtensionExceptionCheck(output, ".webm");

            string conversionArgs = string.Format("-i \"{0}\" -threads {1} {2} -vcodec libvpx -quality good -cpu-used 0 -b:v 1500k -qmin 10 -qmax 42 -maxrate 500k -bufsize 1000k -codec:a libvorbis -b:a 128k \"{3}\"", source.Path,
                                                                                                                                                                                                                         threadCount,
                                                                                                                                                                                                                         scale,
                                                                                                                                                                                                                         output);

            return _RunProcess(conversionArgs);
        }
Beispiel #38
0
 /// <summary>
 /// Converts a source video to WebM format.
 /// </summary>
 /// <param name="source">Source video file.</param>
 /// <param name="output">Output video file.</param>
 /// <param name="size">Output video size.</param>
 /// <param name="multithread">Use multithreading for conversion.</param>
 /// <returns>Success state.</returns>
 public bool ToWebM(string source, string output, VideoSize size = VideoSize.Original, bool multithread = false)
 {
     return ToWebM(new VideoInfo(source), output, size, multithread);
 }
Beispiel #39
0
 /// <summary>
 /// Initializes a video stream of optimal settings.
 /// </summary>
 /// <param name="xbox"></param>
 public XboxVideoStream(Xbox xbox)
 {
     Xbox = xbox;
     this.size = VideoSize.Medium;
     Quality = VideoQuality.Regular;
     Interval = VideoPresentationInterval.Two;
 }
Beispiel #40
0
        public XboxVideoStream(Xbox xbox, VideoSize size, VideoQuality quality, VideoPresentationInterval interval)
        {
            Xbox = xbox;
            this.size = size;
            Quality = quality;
            Interval = interval;

            // todo: check memory requirements
            // 152kb (38 4kb pages) for medium size and normal quality
            // 604kb (151 4kb pages) for full size and normal quality

            // calculate width*height*quality+1 and round up to next 4kb page

            //640*480*16

            //throw new OutOfMemoryException("Not enough memory present to initialize the stream.");

        }
 public void LoadRelatedVideoContent(string videoSourceUrl, VideoSize videoSize)
 {
     if (HasRelatedContentPanel)
     {
         if (RelatedContentController != null)
         {
             string sizeValue = videoSize.ToString().ToLower();
             RelatedContentController.Invoke("loadRelatedContent", "video", HttpUtility.UrlEncode(videoSourceUrl), sizeValue);
         }
     }
 }
Beispiel #42
0
        /// <summary>
        /// Converts a source video to MP4 format.
        /// </summary>
        /// <param name="source">Source video file.</param>
        /// <param name="output">Output video file.</param>
        /// <param name="speed">Conversion speed preset.</param>
        /// <param name="size">Output video size.</param>
        /// <param name="multithread">Use multithreading for conversion.</param>
        /// <returns>Success state.</returns>
        public bool ToMP4(VideoInfo source, string output, Speed speed = Speed.SuperFast, VideoSize size = VideoSize.Original, bool multithread = false)
        {
            _probe.SetVideoInfo(ref source);
            _totalVideoTime = source.Duration;
            IsConverting = true;

            string threadCount = multithread ?
                                Environment.ProcessorCount.ToString() : "1",
                                scale = FFMpegHelper.GetScale(size);

            FFMpegHelper.ConversionExceptionCheck(source, output);
            FFMpegHelper.ExtensionExceptionCheck(output, ".mp4");

            string conversionArgs = string.Format("-i \"{0}\" -threads {1} {2} -b:v 2000k -vcodec libx264 -preset {3} -g 30 \"{4}\"", source.Path,
                                                                                                                                       threadCount,
                                                                                                                                       scale,
                                                                                                                                       speed.ToString().ToLower(),
                                                                                                                                       output);

            return _RunProcess(conversionArgs);
        }