Opened 19 months ago

#10042 new defect

Setting non-default enc_time_base breaks fps_mode cfr/vfr

Reported by: Xiaolei Yu Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
The vsync code in do_video_out incorrectly assumes that the time base of incoming frames equals to 1/frame_rate.

I previously sumbitted a patch that fixes cases when frame_rate/enc_time_base is an integer.

https://patchwork.ffmpeg.org/project/ffmpeg/patch/bf9be598-56a1-3461-37c3-79df4fb09cb7@gmail.com/

How to reproduce:

The following command output is 30 fps instead of requested 15 fps:

$ 
ffmpeg -f lavfi -i testsrc=r=30:d=1 -fps_mode cfr -r 15 -enc_time_base -1 -c libx264 -f null -
ffmpeg version 5.1.2-1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12 (Debian 12.2.0-3)
  configuration: --prefix=/usr --extra-version=1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, lavfi, from 'testsrc=r=30:d=1':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 320x240 [SAR 1:1 DAR 4:3], 30 tbr, 30 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x55a26fa15600] using SAR=1/1
[libx264 @ 0x55a26fa15600] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55a26fa15600] profile High 4:4:4 Predictive, level 1.2, 4:4:4, 8-bit
Output #0, null, to 'pipe:':
  Metadata:
    encoder         : Lavf59.27.100
  Stream #0:0: Video: h264, yuv444p(tv, progressive), 320x240 [SAR 1:1 DAR 4:3], q=2-31, 15 fps, 30 tbn
    Metadata:
      encoder         : Lavc59.37.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=   30 fps=0.0 q=-1.0 Lsize=N/A time=00:00:00.93 bitrate=N/A speed=23.1x    
video:7kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 @ 0x55a26fa15600] frame I:1     Avg QP:19.99  size:  3572
[libx264 @ 0x55a26fa15600] frame P:8     Avg QP:16.52  size:   369
[libx264 @ 0x55a26fa15600] frame B:21    Avg QP:15.04  size:    47
[libx264 @ 0x55a26fa15600] consecutive B-frames:  6.7%  0.0%  0.0% 93.3%
[libx264 @ 0x55a26fa15600] mb I  I16..4: 36.3% 37.7% 26.0%
[libx264 @ 0x55a26fa15600] mb P  I16..4:  2.1%  1.3%  0.5%  P16..4:  8.8%  3.7%  1.5%  0.0%  0.0%    skip:82.2%
[libx264 @ 0x55a26fa15600] mb B  I16..4:  0.3%  0.0%  0.0%  B16..8:  3.2%  0.1%  0.0%  direct: 0.1%  skip:96.3%  L0:41.3% L1:54.1% BI: 4.6%
[libx264 @ 0x55a26fa15600] 8x8 transform intra:35.4% inter:45.0%
[libx264 @ 0x55a26fa15600] coded y,u,v intra: 11.4% 10.9% 9.2% inter: 0.6% 0.6% 0.5%
[libx264 @ 0x55a26fa15600] i16 v,h,dc,p: 62% 26%  5%  6%
[libx264 @ 0x55a26fa15600] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 63% 11% 26%  1%  0%  0%  0%  0%  0%
[libx264 @ 0x55a26fa15600] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 44% 30% 19%  2%  1%  2%  0%  2%  0%
[libx264 @ 0x55a26fa15600] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55a26fa15600] ref P L0: 69.8%  7.4% 18.4%  4.3%
[libx264 @ 0x55a26fa15600] ref B L0: 67.4% 32.6%
[libx264 @ 0x55a26fa15600] ref B L1: 99.2%  0.8%
[libx264 @ 0x55a26fa15600] kb/s:60.07

Change History (0)

Note: See TracTickets for help on using tickets.