Azure-Samples / media-services-v3-dotnet

The projects in this repository show how to implement different Azure Media Services scenarios using the v3 version.
MIT License
58 stars 52 forks source link

Add Sample demonstrating the use of the new CFR Rate Control mode. #47

Closed johndeu closed 1 year ago

johndeu commented 3 years ago

There are now new Rate control modes on the encoder. It would be great to have a sample showing how to set the CRF mode on the encoder - since that is a common ask. The CBR mode is less commonly asked for, but we have had a few customers that need it to hit a target bitrate.

CRF mode is similar to constrained VBR.

(RateControlMode setting is highlighted and its default value is H264RateControlMode.ABR)

CBR mode: var preset = new StandardEncoderPreset { Codecs = { new AacAudio(), new H264Video() { RateControlMode = H264RateControlMode.CBR, Layers = { new H264Layer { Bitrate = 2000000, Width = "1280", Height = "720" } } } },

     Formats =
     {
       new Mp4Format
      {
         FilenamePattern = "{Basename}_{Bitrate}{Extension}"
       }
     }
   }

CRF mode: var preset = new StandardEncoderPreset { Codecs = { new AacAudio(), new H264Video() { RateControlMode = H264RateControlMode.CRF, Layers = { new H264Layer { Crf = 28, Bitrate = 2000000, Width = "1280", Height = "720" } } } },

Formats = { new Mp4Format { FilenamePattern = "{Basename}_{Bitrate}{Extension}" } } }

johndeu commented 1 year ago

Resolving this one with new sample. Thanks @xpouyat !