[FFmpeg-user] FFmpeg's H264 and HEVC QSV encoder wrappers not obeying the set GOP size parameter value via -g:v

Dennis Mungai dmngaie at gmail.com
Mon Dec 18 01:24:28 EET 2023


On Mon, 18 Dec 2023 at 02:23, Dennis Mungai <dmngaie at gmail.com> wrote:

> On Mon, 18 Dec 2023 at 00:55, Dennis Mungai <dmngaie at gmail.com> wrote:
>
>> Hello there,
>>
>> As tested with FFmpeg 6.1 and git tip master, FFmpeg's H.264 and HEVC QSV
>> encoder wrappers, ie h264_qsv and hevc_qsv are not accepting the configured
>> GOP size(s) set via the generic option -g:v.
>>
>> A trivial command such as the one shows below demonstrates the failure:
>>
>> ffmpeg -thread_queue_size 5120 -nostdin -y -fflags +genpts -y \
>> -init_hw_device vaapi=va:/dev/dri/renderD129 \
>> -init_hw_device qsv=qs at va \
>> -filter_hw_device qs \
>> -extra_hw_frames 64 \
>> -threads:v 2 -async 1 \
>> -probesize 10M -analyzeduration 10M \
>> -f mpegts -fix_teletext_pts 1 -scan_all_pmts 1 -merge_pmt_versions 1 \
>> -i "input.ts" \
>> -vf 'hwmap=derive_device=qsv,format=qsv,vpp_qsv=deinterlace=2:scale_mode=0:async_depth=4' \
>> -sc_threshold 0 -strict -1 -bitrate_limit:v 0 -g:v 50 -async_depth:v 4 -look_ahead_depth:v 40 \
>> -preset:v medium -refs:v 5 -extbrc:v 1 -bf:v 0 -low_power:v 1 -r:v 25 \
>> -b:v 4500k -minrate:v 4500k -maxrate:v 4500k -bufsize:v 9000k -rc_init_occupancy:v 4500k -c:v h264_qsv \
>> -c:a aac -ac 2 -b:a 128k \
>> -flags -global_header+cgop -max_muxing_queue_size 2048 -max_interleave_delta 0 -flush_packets 0 -fps_mode cfr -f mpegts \
>> -y "out.ts"
>>
>>
>> And when the output is analyzed with ffprobe via:
>>
>> ffprobe -select_streams v -show_entries frame=pict_type,pts_time -of csv=p=0 -skip_frame nokey -i filter.ts > Iframes.txt
>>
>>
>> The GOP distance is clearly set to 10, instead of the specified value of
>> 2:
>>
>> less Iframes.txt
>> 2.981333,I
>> 13.221333,I
>> 23.461333,I
>> 33.701333,I
>> 43.941333,I
>> 54.181333,I
>> 64.421333,I
>> 74.661333,I
>> 84.901333,I
>> 95.141333,I
>> 105.381333,I
>> 115.621333,I
>> 125.861333,I
>> 136.101333,I
>> 146.341333,I
>> 156.581333,I
>> 166.821333,I
>>
>>
>> I'll attach the sample file below demonstrating the anomalous GOP size
>> issue after encoding.
>> Copying in Xiang and Artem.
>>
>> Warm regards,
>>
>> Dennis.
>>
>

Hello there,

I fixed it. The root cause of this anomaly is due to the external bit rate
control mode in use (-extbrc 1) which also enables mini-GOPs and scenecut
detection.
Both of these options can be disabled by passing  -adaptive_i 0 -adaptive_b
0


More information about the ffmpeg-user mailing list