[Question]: how to avoid the frame flashing while the bitrate not overload?
AMF 264 codec when set the bitrate control to VBR, 1080p 60fps with B frame switched on, target bitrate is 10000kbps while the maxbitrate is 15000kbps,but sometimes the bitrate reached 20000kbps. If the maxbitrate less than 14000kbps the video frame will flash. Is there a good way to make the video frame neither bitrate overloading nor flashing?
What is full set of encoder parameters you use? Which GPU?
the GPU is RX6600M and the codec parameters now listed: AMF_VIDEO_ENCODER_FRAMESIZE: 1920*1080 AMF_VIDEO_ENCODER_USAGE: 0 AMF_VIDEO_ENCODER_FRAMERATE: 60 AMF_VIDEO_ENCODER_QUALITY_PRESET: 2 AMF_VIDEO_ENCODER_PROFILE: 100 AMF_VIDEO_ENCODER_ASPECT_RATIO: 1 AMF_VIDEO_ENCODER_LOWLATENCY_MODE: false AMF_VIDEO_ENCODER_CABAC_ENABLE: AMF_VIDEO_ENCODER_UNDEFINED AMF_VIDEO_ENCODER_FULL_RANGE_COLOR: true AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD: 2 AMF_VIDEO_ENCODER_MAX_NUM_REFRAMES: 0 AMF_VIDEO_ENCODER_TARGET_BITRATE: 10000000 AMF_VIDEO_ENCODER_PEAK_BITRATE: 14000000 AMF_VIDEO_ENCODER_VBV_BUFFER_SIZE: 15000000 AMF_VIDEO_ENCODER_ENFORCE_HRD: true AMF_VIDEO_ENCODER_HIGH_MOTION_QUALITY_BOOST_ENABLEfalse: false AMF_VIDEO_ENCODER_FILLER_DATA_ENABLE: false AMF_VIDEO_ENCODER_RATE_CONTROL_SKIP_FRAME_ENABLE: false AMF_VIDEO_ENCODER_ENABLE_VBAQ: true AMF_VIDEO_ENCODER_DE_BLOCKING_FILTER: true AMF_VIDEO_ENCODER_B_PIC_PATTERN: 2 AMF_VIDEO_ENCODER_MAX_CONSECUTIVE_BPICTURES: 2 AMF_VIDEO_ENCODER_B_PIC_DELTA_QP: 4 AMF_VIDEO_ENCODER_B_REFERENCE_ENABLE: false AMF_VIDEO_ENCODER_REF_B_PIC_DELTA_QP: 2 AMF_VIDEO_ENCODER_IDR_PERIOD: 120 AMF_VIDEO_ENCODER_HEADER_INSERTION_SPACING: 0 AMF_VIDEO_ENCODER_SLICES_PER_FRAME: 1 AMF_VIDEO_ENCODER_CABAC_ENABLE: AMF_VIDEO_ENCODER_UNDEFINED AMF_VIDEO_ENCODER_PREENCODE_ENABLE: AMF_VIDEO_ENCODER_PREENCODE_ENABLED AMF_VIDEO_ENCODER_MOTION_HALF_PIXEL: true AMF_VIDEO_ENCODER_MOTION_QUARTERPIXEL: true
Parameters seems OK.
- Does it flash on IDR frames (every 2 seconds)?
- Could you please share the flashing stream?
- What does happen if you disable B-frames?
- Which driver version do you use (try the latest)?
Does it flash on IDR frames (every 2 seconds)? NO, only when the frame content is too complex the flashing will appear. i use 3DMarks11 to generate the frames, when the frame filled full with tiny lines and some point lights flashing on background at the same time, the encoded frames will be bad.
Could you please share the flashing stream? the problem can be repeated easily, download the 3Dmarks 11, select the [Graphics Test3] and [Graphics Test4] then click the [run custom] button, record the window frames with AMF H264 codec.
What does happen if you disable B-frames? if the B frames disabled,the peak bitrate will overload, almost 20000kbps.
Which driver version do you use (try the latest)? the driver version is 31.0.14037.1007.
thanks for your help.
https://user-images.githubusercontent.com/12590034/230820778-b4654cfb-8d40-4330-9289-0632076ab6d3.mp4
5sec position here is the problem frame.
The video shows not flashing but corruption.
- Which application are you using to record the video?
- As you are using B-frames, encoder keeps references to the input frames till they are not actually reordered and encoded: B_PIC_PATTERN+1. Does the app guarantee that the input frames are not reused while they are used by the encoder?
- Can you reproduce the issue with one of AMF samples?
Which application are you using to record the video? the self developed app to record the video and the function just like OBS
As you are using B-frames, encoder keeps references to the input frames till they are not actually reordered and encoded: B_PIC_PATTERN+1. Does the app guarantee that the input frames are not reused while they are used by the encoder? the input frame are not reused by the other callers, i am sure. what is more when i change the GPU to RX6700M, a big improvement of the corruption problem can be seen, still using RX6600M when i enlarge the AMF_VIDEO_ENCODER_PEAK_BITRATE and AMF_VIDEO_ENCODER_VBV_BUFFER_SIZE both to 20000000kbps, the frame corruption disappeared.
Can you reproduce the issue with one of AMF samples? i am not try it, but the same app when i change the encoder to Intel h264/nv264/x264,they are all OK.
The codecs in RX6700M and RX6600M are the same but performance could be different. The different performance causes different timing and may explain the lack of corruption. The same for huge bitrate. Other codecs may have different implementation in the way how inputs are used and/or different timing. IMHO, we deal with corruption, it cannot be fixed with parameter tweaking. It could be an application issue of AMF/driver issue. If the latter, we need to reproduce the problem in-house. AMF samples is the best way to do it. Note, AMD ReLive is similar to OBS, do you see the corruption there?