[FFmpeg-trac] #10735(avcodec:new): FFmpeg 6.1 qsv encoder wrappers broken with the -g parameter set, cannot enforce set keyframe interval

FFmpeg trac at avcodec.org
Fri Dec 15 02:30:50 EET 2023


#10735: FFmpeg 6.1 qsv encoder wrappers broken with the -g parameter set, cannot
enforce set keyframe interval
-------------------------------------+-------------------------------------
             Reporter:  Dennis E.    |                    Owner:  (none)
  Mungai                             |
                 Type:  defect       |                   Status:  new
             Priority:  critical     |                Component:  avcodec
              Version:  6.0          |               Resolution:
             Keywords:  quicksync    |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------
Description changed by Dennis E. Mungai:

Old description:

> **Summary of the bug:**
>
> Any invocation of the {{{h264_qsv}}} encoder with a set GOP size via the
> {{{-g}}} option results with the specified GOP size(s) not being
> respected.
>
> **Sample command:**
>
> The trivial example below demonstrates this anomaly with ffmpeg v6.1:
>
> {{{
> 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 60
> -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"
> }}}
>
> The same command ran on FFmpeg git tip build produces an output
> conformant with the required GOP size specified via the {{{-g:v 50}}}
> parameter.
>
> This was verified with {{{ffprobe}}} as shown:
>
> {{{
> ffprobe -select_streams v -show_entries frame=pict_type,pts_time -of
> csv=p=0 -skip_frame nokey -i filter.ts > Iframes.txt
> }}}
>

> Which showed an abnormal GOP size of 10 being set as per sample:
>
> {{{
>
> 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
> }}}
>
> The sample encode from ffmpeg 6.1 showing the bug above is attached.

New description:

 **Summary of the bug:**

 Any invocation of the {{{h264_qsv}}} encoder with a set GOP size via the
 {{{-g}}} option results with the specified GOP size(s) not being
 respected.

 **Sample command:**

 The trivial example below demonstrates this anomaly with ffmpeg v6.1:

 {{{
 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"
 }}}

 The same command ran on FFmpeg git tip build produces an output conformant
 with the required GOP size specified via the {{{-g:v 50}}} parameter.

 This was verified with {{{ffprobe}}} as shown:

 {{{
 ffprobe -select_streams v -show_entries frame=pict_type,pts_time -of
 csv=p=0 -skip_frame nokey -i filter.ts > Iframes.txt
 }}}


 Which showed an abnormal GOP size of 10 being set as per sample:

 {{{

 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
 }}}

 The sample encode from ffmpeg 6.1 showing the bug above is attached.

--
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/10735#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list