[FFmpeg-user] has setpts filter been changed?

William C Bonner wimbonner at gmail.com
Thu Aug 8 16:49:11 EEST 2024


I use setpts to speed up some video that I'm concatenating from my car's
dashcam. The process is consistent and hasn't changed recently. Here's an
example command line:

C:\Windows\ffmpeg.exe -hide_banner -i
D:\ROAV\MOVIE\2024_0803_173613_229.MP4 -i
D:\ROAV\MOVIE\2024_0803_173713_230.MP4 -i
D:\ROAV\MOVIE\2024_0803_173813_231.MP4 -i
D:\ROAV\MOVIE\2024_0803_173913_232.MP4 -i
D:\ROAV\MOVIE\2024_0803_174013_233.MP4 -i
D:\ROAV\MOVIE\2024_0803_174113_234.MP4 -i
D:\ROAV\MOVIE\2024_0803_174213_235.MP4 -i
D:\ROAV\MOVIE\2024_0803_174313_236.MP4 -i
D:\ROAV\MOVIE\2024_0803_174413_237.MP4 -i
D:\ROAV\MOVIE\2024_0803_174513_238.MP4 -i
D:\ROAV\MOVIE\2024_0803_174613_239.MP4 -i
D:\ROAV\MOVIE\2024_0803_174713_240.MP4 -i
D:\ROAV\MOVIE\2024_0803_174813_241.MP4 -i
D:\ROAV\MOVIE\2024_0803_174913_242.MP4 -i
D:\ROAV\MOVIE\2024_0803_175013_243.MP4 -i
D:\ROAV\MOVIE\2024_0803_175113_244.MP4 -i
D:\ROAV\MOVIE\2024_0803_175213_245.MP4 -i
D:\ROAV\MOVIE\2024_0803_175313_246.MP4 -i
D:\ROAV\MOVIE\2024_0803_175413_247.MP4 -i
D:\ROAV\MOVIE\2024_0803_175513_248.MP4 -i
D:\ROAV\MOVIE\2024_0803_175613_249.MP4 -i
D:\ROAV\MOVIE\2024_0803_175713_250.MP4 -i
D:\ROAV\MOVIE\2024_0803_175813_251.MP4 -i
D:\ROAV\MOVIE\2024_0803_175913_252.MP4 -i
D:\ROAV\MOVIE\2024_0803_180013_253.MP4 -i
D:\ROAV\MOVIE\2024_0803_180113_254.MP4 -i
D:\ROAV\MOVIE\2024_0803_180213_255.MP4 -filter_complex
[0:v][1:v][2:v][3:v][4:v][5:v][6:v][7:v][8:v][9:v][10:v][11:v][12:v][13:v][14:v][15:v][16:v][17:v][18:v][19:v][20:v][21:v][22:v][23:v][24:v][25:v][26:v]concat=n=27:v=1[v];[v]setpts=(1/60)*PTS,drawtext=fontfile=C\\:/Windows/Fonts/consola.ttf:fontcolor=white:fontsize=80:y=main_h-text_h-50:x=50:text=WimsWorld[o]
-map [o] -map_metadata -1 -c:v libx265 -crf 23 -preset veryfast -movflags
+faststart -bf 2 -g 15 -pix_fmt yuv420p -n D:\ROAV\20240803-BMW.mp4

The important part is setpts=(1/60)*PTS which should convert 1 minute of
the source video to 1 second in the destination

I noticed that watching recent videos strangely seemed much smoother, then
realized that they were also significantly larger.

https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video
still says that using this method will drop frames, but when I ran ffprobe
on the current file I got:

C:\Users\Wim>ffprobe d:\ROAV\20240803-BMW.mp4
ffprobe version 2024-07-18-git-fa5a605542-full_build-www.gyan.dev Copyright
(c) 2007-2024 the FFmpeg developers
  built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static
--disable-w32threads --disable-autodetect --enable-fontconfig
--enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib
--enable-lzma --enable-libsnappy --enable-zlib --enable-librist
--enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth
--enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24
--enable-libaribcaption --enable-libdav1d --enable-libdavs2
--enable-libopenjpeg --enable-libquirc --enable-libuavs3d --enable-libxevd
--enable-libzvbi --enable-libqrencode --enable-librav1e --enable-libsvtav1
--enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom
--enable-libjxl --enable-libvpx --enable-mediafoundation --enable-libass
--enable-frei0r --enable-libfreetype --enable-libfribidi
--enable-libharfbuzz --enable-liblensfun --enable-libvidstab
--enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm
--enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va
--enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc
--enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo
--enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug
--enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame
--enable-libshine --enable-libtheora --enable-libtwolame
--enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm
--enable-libopencore-amrnb --enable-libopus --enable-libspeex
--enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite
--enable-libmysofa --enable-librubberband --enable-libsoxr
--enable-chromaprint
  libavutil      59. 28.100 / 59. 28.100
  libavcodec     61. 10.100 / 61. 10.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd:\ROAV\20240803-BMW.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf61.5.101
  Duration: 00:00:27.07, start: 0.000000, bitrate: 889896 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main) (hev1 / 0x31766568),
yuv420p(tv, progressive), 2560x1440, 889591 kb/s, 1800.04 fps, 1000k tbr,
1000k tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.10.100 libx265

Running it on an older file produced:

C:\Users\Wim>ffprobe d:\ROAV\20240523-BMW.mp4
ffprobe version 2024-07-18-git-fa5a605542-full_build-www.gyan.dev Copyright
(c) 2007-2024 the FFmpeg developers
  built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static
--disable-w32threads --disable-autodetect --enable-fontconfig
--enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib
--enable-lzma --enable-libsnappy --enable-zlib --enable-librist
--enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth
--enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24
--enable-libaribcaption --enable-libdav1d --enable-libdavs2
--enable-libopenjpeg --enable-libquirc --enable-libuavs3d --enable-libxevd
--enable-libzvbi --enable-libqrencode --enable-librav1e --enable-libsvtav1
--enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom
--enable-libjxl --enable-libvpx --enable-mediafoundation --enable-libass
--enable-frei0r --enable-libfreetype --enable-libfribidi
--enable-libharfbuzz --enable-liblensfun --enable-libvidstab
--enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm
--enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va
--enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc
--enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo
--enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug
--enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame
--enable-libshine --enable-libtheora --enable-libtwolame
--enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm
--enable-libopencore-amrnb --enable-libopus --enable-libspeex
--enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite
--enable-libmysofa --enable-librubberband --enable-libsoxr
--enable-chromaprint
  libavutil      59. 28.100 / 59. 28.100
  libavcodec     61. 10.100 / 61. 10.100
  libavformat    61.  5.101 / 61.  5.101
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.102 / 10.  2.102
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'd:\ROAV\20240523-BMW.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf61.3.103
  Duration: 00:09:40.88, start: 0.000000, bitrate: 26675 kb/s
  Stream #0:0[0x1](und): Video: hevc (Main) (hev1 / 0x31766568),
yuv420p(tv, progressive), 2560x1440, 26672 kb/s, 25 fps, 25 tbr, 12800 tbn
(default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.5.104 libx265

The important difference is that the older file reports 2560x1440, 26672
kb/s, 25 fps, 25 tbr, 12800 tbn and the newer file reports 2560x1440,
889591 kb/s, 1800.04 fps, 1000k tbr, 1000k tbn.

This seems that the new code speed up the reported fps without dropping any
frames.


More information about the ffmpeg-user mailing list