Opened 3 months ago

Closed 2 months ago

Last modified 2 months ago

#11086 closed defect (invalid)

Using -setpts unsets fps starting with commit 43fd3d5df6a1

Reported by: ivyl Owned by:
Priority: normal Component: ffmpeg
Version: 7.0 Keywords: pts
Cc: ivyl Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

Starting with 43fd3d5df6a1 ("lavf/vf_setpts: unset output framerate") using -setpts causes fps to be unset.

How to reproduce:

% ffmpeg -i Big_Buck_Bunny_4K.mp4 -vf setpts=N/FRAME_RATE/TB -c:v libsvtav1 -f matroska out.mkv
ffmpeg version n7.0.1 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14.1.1 (GCC) 20240522
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto --enable-fontconfig --enable-frei0r --enable-gmp --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libdvdnav --enable-libdvdread --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-mbedtls --enable-nvdec --enable-nvenc --enable-opencl --enable-opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-vulkan
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Big_Buck_Bunny_4K.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : Big Buck Bunny 4K - https://archive.org/details/big-buck-bunny-4k
    encoder         : Lavf58.51.100
    comment         : license:https://creativecommons.org/licenses/by-nd/4.0/
  Duration: 00:10:34.57, start: 0.000000, bitrate: 796 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(progressive), 854x480 [SAR 1280:1281 DAR 16:9], 678 kb/s, 60 fps, 60 tbr, 15360 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 104 kb/s (default)
      Metadata:
        handler_name    : SoundHandler
        vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> av1 (libsvtav1))
  Stream #0:1 -> #0:1 (aac (native) -> vorbis (libvorbis))
Press [q] to stop, [?] for help
Svt[info]: -------------------------------------------
Svt[info]: SVT [version]:	SVT-AV1 Encoder Lib v2.1.0-dirty
Svt[info]: SVT [build]  :	GCC 14.1.1 20240507	64 bit
Svt[info]: LIB Build date: May 20 2024 19:45:55
Svt[info]: -------------------------------------------
Svt[error]: Instance 1: The maximum allowed frame rate is 240 fps
[libsvtav1 @ 0x58b6dc1c1cc0] Error setting encoder parameters: bad parameter (0x80001005)
SvtMalloc[info]: you have no memory leak
[vost#0:0/libsvtav1 @ 0x58b6dc1bfa80] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
[vf#0:0 @ 0x58b6dc1c0100] Error sending frames to consumers: Invalid argument
[vf#0:0 @ 0x58b6dc1c0100] Task finished with error code: -22 (Invalid argument)
[vf#0:0 @ 0x58b6dc1c0100] Terminating thread with return code -22 (Invalid argument)
[vost#0:0/libsvtav1 @ 0x58b6dc1bfa80] Could not open encoder before EOF
[vost#0:0/libsvtav1 @ 0x58b6dc1bfa80] Task finished with error code: -22 (Invalid argument)
[vost#0:0/libsvtav1 @ 0x58b6dc1bfa80] Terminating thread with return code -22 (Invalid argument)
[out#0/matroska @ 0x58b6dc2d1880] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0KiB time=N/A bitrate=N/A speed=N/A    
Conversion failed!

The relevant error is Svt[error]: Instance 1: The maximum allowed frame rate is 240 fps. Before the mentioned commit the original fps was preserved without an issue.

Change History (2)

comment:1 by ivyl, 2 months ago

I've noticed that some encoders, like libx264 succeed so I wanted to see what's going on with framerate:

diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 2fef8c897122..bf8bcf0a4e26 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -320,6 +320,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
     }
 
+    av_log(avctx, AV_LOG_WARNING, "num %d, den %d.\n", param->frame_rate_numerator, param->frame_rate_denominator);
+
     /* 2 = IDR, closed GOP, 1 = CRA, open GOP */
     param->intra_refresh_type = avctx->flags & AV_CODEC_FLAG_CLOSED_GOP ? 2 : 1;
 
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index d07a65a103ed..081f6dfbe919 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -1326,6 +1326,8 @@ FF_DISABLE_DEPRECATION_WARNINGS
 FF_ENABLE_DEPRECATION_WARNINGS
     }
 
+    av_log(avctx, AV_LOG_WARNING, "num %d, den %d.\n", x4->params.i_fps_num, x4->params.i_fps_den);
+
     x4->params.analyse.b_psnr = avctx->flags & AV_CODEC_FLAG_PSNR;
 
     x4->params.i_threads      = avctx->thread_count;

[libsvtav1 @ 0x5d0398468c40] num 15360, den 1.

libx264 seems to gate the same nonsensical value:

[libx264 @ 0x5efe21d1cc40] num 15360, den 1.
[libx264 @ 0x5efe21d1cc40] using SAR=1280/1281
[libx264 @ 0x5efe21d1cc40] MB rate (24883200) > level limit (16711680)

but just recovers better than svtav1.

comment:2 by elenril, 2 months ago

Resolution: invalid
Status: newclosed

Not a bug. setpts can set output timestamps to anything, so preserving output framerate is wrong.

Version 0, edited 2 months ago by elenril (next)
Note: See TracTickets for help on using tickets.