1 Reply Latest reply on Nov 18, 2015 8:51 AM by vladimir

    AMF VCE - Wrong encoding bitrate (fps)

    vladimir

      We find strange behavior. For example, we trying to encode 1280x720, 60 fps so we set following settings (vce2 is just for AMF implementation, old one uses OVE):

      [8092] ext_h264vce2enc (1280, 720, 0, 1, 6000, 100, 0, 4), FrameRate:60&TargetBitrate:250000&RateControlMethod:1&IDRPeriod:60&VBVBufferSize:250000&Profile:77&ENGINE:DX11&RateControlMethod:1&PeakBitrate:250000&QualityPreset:0&Profile:100&ProfileLevel:4.1&BPicturesPattern:0&FillerDataEnable:1

      [4524] vce2_setparam(FrameRate, 6000,100) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(FrameRate, 60) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(TargetBitrate, 250000) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(RateControlMethod, 1) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(IDRPeriod, 60) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(VBVBufferSize, 250000) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(Profile, 77) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(ENGINE, DX11) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(RateControlMethod, 1) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(PeakBitrate, 250000) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(QualityPreset, 0) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(Profile, 100) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(ProfileLevel, 4.1) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(BPicturesPattern, 0) returns 0x00000000 (AMF_OK)

      [4524] vce2_setparam(FillerDataEnable, 1) returns 0x00000000 (AMF_OK)

       

      Then for self control we log all stored settings:

      [4524] VCE2 param log: BPICTURESPATTERN = 0

      [4524] VCE2 param log: ENGINE = DX11

      [4524] VCE2 param log: FILLERDATAENABLE = true

      [4524] VCE2 param log: FRAMERATE = 60

      [4524] VCE2 param log: IDRPERIOD = 60

      [4524] VCE2 param log: PEAKBITRATE = 250000

      [4524] VCE2 param log: PROFILE = 100

      [4524] VCE2 param log: PROFILELEVEL = 41

      [4524] VCE2 param log: QUALITYPRESET = 0

      [4524] VCE2 param log: RATECONTROLMETHOD = 1

      [4524] VCE2 param log: TARGETBITRATE = 250000

      [4524] VCE2 param log: VBVBUFFERSIZE = 250000

      [4524] DX11: List of adapters:

      [4524]           0: Device ID: 683D [AMD Radeon HD 7700 Series]

      [4524] DX11 : Choosen Device 2: Device ID: 683D [AMD Radeon HD 7700 Series]

       

      Timestamps that we submit to encoder looks following (frame number, timestamp, duration):

      [4524] frame submit: 0, 0 (166666)

      [4524] frame submit: 1, 166666 (166666)

      [4524] frame submit: 2, 333332 (166666)

      [4524] frame submit: 3, 499998 (166666)

      [4524] frame submit: 4, 666664 (166666)

      [4524] frame submit: 5, 833330 (166666)

      [4524] frame submit: 6, 999996 (166666)

      [4524] frame submit: 7, 1166662 (166666)

      [4524] frame submit: 8, 1333328 (166666)

      [4524] frame submit: 9, 1499994 (166666)

      [4524] frame submit: 10, 1666660 (166666)

      [4524] frame submit: 11, 1833326 (166666)

      [4524] frame submit: 12, 1999992 (166666)

      [4524] frame submit: 13, 2166658 (166666)

      [4524] frame submit: 14, 2333324 (166666)

      [4524] frame submit: 15, 2499990 (166666)

      [4524] frame submit: 16, 2666656 (166666)

      [4524] frame submit: 17, 2833322 (166666)

      [4524] frame submit: 18, 2999988 (166666)

      [4524] frame submit: 19, 3166654 (166666)

      [4524] frame submit: 20, 3333320 (166666)

      [4524] frame submit: 21, 3499986 (166666)

      [4524] frame submit: 22, 3666652 (166666)

      [4524] frame submit: 23, 3833318 (166666)

      [4524] frame submit: 24, 3999984 (166666)

      [4524] frame submit: 25, 4166650 (166666)

      [4524] frame submit: 26, 4333316 (166666)

      [4524] frame submit: 27, 4499982 (166666)

      [4524] frame submit: 28, 4666648 (166666)

      [4524] frame submit: 29, 4833314 (166666)

      [4524] frame submit: 30, 4999980 (166666)

      [4524] frame submit: 31, 5166646 (166666)

      [4524] frame submit: 32, 5333312 (166666)

      [4524] frame submit: 33, 5499978 (166666)

      [4524] frame submit: 34, 5666644 (166666)

      [4524] frame submit: 35, 5833310 (166666)

      [4524] frame submit: 36, 5999976 (166666)

      [4524] frame submit: 37, 6166642 (166666)

      [4524] frame submit: 38, 6333308 (166666)

      [4524] frame submit: 39, 6499974 (166666)

      [4524] frame submit: 40, 6666640 (166666)

      [4524] frame submit: 41, 6833306 (166666)

      [4524] frame submit: 42, 6999972 (166666)

      [4524] frame submit: 43, 7166638 (166666)

      [4524] frame submit: 44, 7333304 (166666)

      [4524] frame submit: 45, 7499970 (166666)

      [4524] frame submit: 46, 7666636 (166666)

      [4524] frame submit: 47, 7833302 (166666)

      [4524] frame submit: 48, 7999968 (166666)

      [4524] frame submit: 49, 8166634 (166666)

      [4524] frame submit: 50, 8333300 (166666)

      [4524] frame submit: 51, 8499966 (166666)

      [4524] frame submit: 52, 8666632 (166666)

      [4524] frame submit: 53, 8833298 (166666)

      [4524] frame submit: 54, 8999964 (166666)

      [4524] frame submit: 55, 9166630 (166666)

      [4524] frame submit: 56, 9333296 (166666)

      [4524] frame submit: 57, 9499962 (166666)

      [4524] frame submit: 58, 9666628 (166666)

      [4524] frame submit: 59, 9833294 (166666)

      [4524] frame submit: 60, 9999960 (166666)

      i.e. frame number 60 have 0,999996 sec timestamp (almost 1 sec), and all next frames looks also same, so we submit real 60 fps per second.

       

      But MediaInfo shows following:

      Video

      ID                                       : 1

      Format                                   : AVC

      Format/Info                              : Advanced Video Codec

      Format profile                           : High@L4.1

      Format settings, CABAC                   : Yes

      Format settings, ReFrames                : 4 frames

      Format settings, GOP                     : M=1, N=30

      Codec ID                                 : avc1

      Codec ID/Info                            : Advanced Video Coding

      Duration                                 : 1mn 5s

      Bit rate                                 : 1 005 Kbps

      Width                                    : 1 280 pixels

      Height                                   : 720 pixels

      Display aspect ratio                     : 16:9

      Frame rate mode                          : Constant

      Frame rate                               : 60.000 fps

      Original frame rate                      : 15.000 fps

      Standard                                 : Component

      Color space                              : YUV

      Chroma subsampling                       : 4:2:0

      Bit depth                                : 8 bits

      Scan type                                : Progressive

      Bits/(Pixel*Frame)                       : 0.018

      Stream size                              : 7.87 MiB (88%)

      Color range                              : Limited

       

      It is very strange that Original frame rate is always Frame rate / 4. For example, if we trying to encode 30 fps, Original frame rate is 7.5 fps. From what I understand is Original frame rate is what encoded in video stream, and Frame rate is container frame rate. So to get 1mbit bitrate we need to set 250kbit, i.e. divide bitrate that we need by 4. Can you please help to understand what we maybe doing wrong?

        • Re: AMF VCE - Wrong encoding bitrate (fps)
          vladimir

          Since our component that uses AMF receives encoder settings as string, it calls ParametersStorage::SetParamAsString for every parameter. So all parameters that have converters implemented works properly, all int64/rate parameters don't have converters and assigned as strings instead of proper type (during development we assume that parameters will be converted from string to proper type).

          It seems after we add converters we have proper result (still waiting for response from testers but at least I don't see Frame rate / Original frame rate issue now).

          FYI

          static AMF_RESULT ParamConverterI64(const std::wstring& value,

            amf::AMFVariant& valueOut)

          {

            valueOut = amf_int64(_wtoi64(value.c_str()));

            return AMF_OK;

          }

           

           

          static AMF_RESULT ParamConverterRate(const std::wstring& value,

            amf::AMFVariant& valueOut)

          {

            wchar_t *p = wcschr((wchar_t *) value.c_str(), L',');

            AMFRate rate;

            if (p != NULL) {

            std::wstring num(value.c_str(), p - value.c_str());

            rate.num = wcstoul(num.c_str(), NULL, 10);

            rate.den = wcstoul(p + 1, NULL, 10);

            } else {

            rate.num = wcstoul(value.c_str(), NULL, 10);

            rate.den = 1;

            }

            valueOut.type = amf::AMF_VARIANT_RATE;

            valueOut.rateValue = rate;

            return AMF_OK;

          }

           

          and then in RegisterEncoderParams (and where you register custom parameters) just add proper converters to all parameters that don't have converters (FrameRate will use ParamConverterRate, all other will use ParamConverterI64, no converter for ENGINE since it is string). Now you can use SetParamAsString always and don't care about parameter type.

          1 of 1 people found this helpful