Exemple #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="width">Width of frame in pixels</param>
 /// <param name="height">Height of frame in pixels</param>
 /// <param name="bitrate">The bitrate in kb/s</param>
 /// <param name="preset">h264 preset</param>
 public Quality(int width, int height, int bitrate, H264Preset preset)
 {
     Width   = width;
     Height  = height;
     Bitrate = bitrate;
     Preset  = preset;
 }
Exemple #2
0
        /// <summary>
        /// Applies an ffmpeg preset to set encoding performance.
        /// </summary>
        public FFmpegH264VideoCommandBuilder WithPreset(H264Preset preset)
        {
            if (preset == H264Preset.None)
            {
                return(this);
            }

            TryAddSimpleCommand($"-preset {preset.ToString().ToLowerInvariant()}", preset.ToString());
            return(this);
        }
        public FFmpegVideoCommandBuilder WithPreset(H264Preset preset)
        {
            if (preset == H264Preset.none)
            {
                return(this);
            }

            TryAddSimpleCommand($"-preset {preset}", preset.ToString());
            return(this);
        }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="width">Width of frame in pixels</param>
 /// <param name="height">Height of frame in pixels</param>
 /// <param name="bitrate">The bitrate in kb/s</param>
 /// <param name="preset">h264 preset</param>
 /// <param name="profile">h264 profile</param>
 public Quality(int width, int height, int bitrate, H264Preset preset, H264Profile profile)
     : this(width, height, bitrate, preset)
 {
     Profile = profile;
 }
Exemple #5
0
        /// <summary>
        /// Generates a set of qualities from a given DefaultQuality level.
        /// </summary>
        /// <param name="q"></param>
        /// <param name="preset"></param>
        /// <returns></returns>
        public static IEnumerable <IQuality> GenerateDefaultQualities(DefaultQuality q, H264Preset preset)
        {
            switch (q)
            {
            case DefaultQuality.potato:
                return(new List <Quality>()
                {
                    new Quality(1280, 720, 1600, preset),
                    new Quality(854, 480, 800, preset),
                    new Quality(640, 360, 500, preset)
                });

            case DefaultQuality.low:
                return(new List <Quality>()
                {
                    new Quality(1280, 720, 2400, preset),
                    new Quality(1280, 720, 1600, preset),
                    new Quality(640, 360, 700, preset),
                });

            case DefaultQuality.high:
                return(new List <Quality>()
                {
                    new Quality(1920, 1080, 6000, preset),
                    new Quality(1920, 1080, 4000, preset),
                    new Quality(1280, 720, 2000, preset),
                });

            case DefaultQuality.ultra:
                return(new List <Quality>()
                {
                    new Quality(1920, 1080, 8000, preset),
                    new Quality(1920, 1080, 6000, preset),
                    new Quality(1280, 720, 2000, preset),
                });

            default:
                break;
            }

            // Medium/default
            return(new List <Quality>()
            {
                new Quality(1920, 1080, 3400, preset),
                new Quality(1280, 720, 1800, preset),
                new Quality(640, 360, 800, preset),
            });
        }
Exemple #6
0
        public static H264VideoConfiguration CreateConfigurationWithPreset(H264Preset preset, string name)
        {
            switch (preset)
            {
            case H264Preset.ULTRAFAST:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.NONE,
                    BFrames = 0,
                    MvSearchRangeMax = 16,
                    MvPredictionMode = MvPredictionMode.SPATIAL,
                    MotionEstimationMethod = H264MotionEstimationMethod.DIA,
                    Cabac = false,
                    RcLookahead = 0,
                    RefFrames = 1,
                    SubMe = H264SubMe.FULLPEL,
                    Trellis = H264Trellis.DISABLED,
                    Partitions = new List <H264Partition> {
                        H264Partition.NONE
                    }
                });

            case H264Preset.SUPERFAST:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FAST,
                    BFrames = 3,
                    MvSearchRangeMax = 16,
                    MvPredictionMode = MvPredictionMode.SPATIAL,
                    MotionEstimationMethod = H264MotionEstimationMethod.DIA,
                    Cabac = true,
                    RcLookahead = 0,
                    RefFrames = 1,
                    SubMe = H264SubMe.SAD,
                    Trellis = H264Trellis.ENABLED_FINAL_MB,
                    Partitions = new List <H264Partition> {
                        H264Partition.I4X4, H264Partition.I8X8
                    }
                });

            case H264Preset.VERYFAST:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FAST,
                    BFrames = 3,
                    MvSearchRangeMax = 16,
                    MvPredictionMode = MvPredictionMode.SPATIAL,
                    MotionEstimationMethod = H264MotionEstimationMethod.HEX,
                    Cabac = true,
                    RcLookahead = 10,
                    RefFrames = 1,
                    SubMe = H264SubMe.SATD,
                    Trellis = H264Trellis.ENABLED_FINAL_MB,
                    Partitions = new List <H264Partition> {
                        H264Partition.I4X4, H264Partition.I8X8, H264Partition.P8X8, H264Partition.B8X8
                    }
                });

            case H264Preset.FASTER:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FAST,
                    BFrames = 3,
                    MvSearchRangeMax = 16,
                    MvPredictionMode = MvPredictionMode.SPATIAL,
                    MotionEstimationMethod = H264MotionEstimationMethod.HEX,
                    Cabac = true,
                    RcLookahead = 20,
                    RefFrames = 2,
                    SubMe = H264SubMe.QPEL4,
                    Trellis = H264Trellis.ENABLED_FINAL_MB,
                    Partitions = new List <H264Partition> {
                        H264Partition.I4X4, H264Partition.I8X8, H264Partition.P8X8, H264Partition.B8X8
                    }
                });

            case H264Preset.FAST:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FAST,
                    BFrames = 3,
                    MvSearchRangeMax = 16,
                    MvPredictionMode = MvPredictionMode.SPATIAL,
                    MotionEstimationMethod = H264MotionEstimationMethod.HEX,
                    Cabac = true,
                    RcLookahead = 30,
                    RefFrames = 2,
                    SubMe = H264SubMe.RD_IP,
                    Trellis = H264Trellis.ENABLED_FINAL_MB,
                    Partitions = new List <H264Partition> {
                        H264Partition.I4X4, H264Partition.I8X8, H264Partition.P8X8, H264Partition.B8X8
                    }
                });

            case H264Preset.MEDIUM:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FAST,
                    BFrames = 3,
                    MvSearchRangeMax = 16,
                    MvPredictionMode = MvPredictionMode.SPATIAL,
                    MotionEstimationMethod = H264MotionEstimationMethod.HEX,
                    Cabac = true,
                    RcLookahead = 40,
                    RefFrames = 3,
                    SubMe = H264SubMe.RD_ALL,
                    Trellis = H264Trellis.ENABLED_ALL,
                    Partitions = new List <H264Partition> {
                        H264Partition.I4X4, H264Partition.I8X8, H264Partition.P8X8, H264Partition.B8X8
                    }
                });

            case H264Preset.SLOW:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FULL,
                    BFrames = 3,
                    MvSearchRangeMax = 16,
                    MvPredictionMode = MvPredictionMode.AUTO,
                    MotionEstimationMethod = H264MotionEstimationMethod.UMH,
                    Cabac = true,
                    RcLookahead = 50,
                    RefFrames = 5,
                    SubMe = H264SubMe.RD_REF_IP,
                    Trellis = H264Trellis.ENABLED_ALL,
                    Partitions = new List <H264Partition> {
                        H264Partition.ALL
                    }
                });

            case H264Preset.SLOWER:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FULL,
                    BFrames = 3,
                    MvSearchRangeMax = 16,
                    MvPredictionMode = MvPredictionMode.AUTO,
                    MotionEstimationMethod = H264MotionEstimationMethod.UMH,
                    Cabac = true,
                    RcLookahead = 60,
                    RefFrames = 8,
                    SubMe = H264SubMe.RD_REF_ALL,
                    Trellis = H264Trellis.ENABLED_ALL,
                    Partitions = new List <H264Partition> {
                        H264Partition.ALL
                    }
                });

            case H264Preset.VERYSLOW:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FULL,
                    BFrames = 8,
                    MvSearchRangeMax = 24,
                    MvPredictionMode = MvPredictionMode.AUTO,
                    MotionEstimationMethod = H264MotionEstimationMethod.UMH,
                    Cabac = true,
                    RcLookahead = 60,
                    RefFrames = 16,
                    SubMe = H264SubMe.QPRD,
                    Trellis = H264Trellis.ENABLED_ALL,
                    Partitions = new List <H264Partition> {
                        H264Partition.ALL
                    }
                });

            case H264Preset.PLACEBO:
                return(new H264VideoConfiguration
                {
                    Name = name,
                    BAdaptiveStrategy = BAdapt.FULL,
                    BFrames = 16,
                    MvSearchRangeMax = 24,
                    MvPredictionMode = MvPredictionMode.AUTO,
                    MotionEstimationMethod = H264MotionEstimationMethod.TESA,
                    Cabac = true,
                    RcLookahead = 60,
                    RefFrames = 16,
                    SubMe = H264SubMe.FULL_RD,
                    Trellis = H264Trellis.ENABLED_ALL,
                    Partitions = new List <H264Partition> {
                        H264Partition.ALL
                    }
                });

            default:
                throw new ArgumentOutOfRangeException(nameof(preset), preset, null);
            }
        }