dfaker / WebmGenerator

UI and Automation to cut, filter and join high quality webms, mp4s or gifs.
Mozilla Public License 2.0
517 stars 33 forks source link

Webm's (vp8 and vp9) encode at extremely low bitrates when speed is adjusted #113

Open Mojavve opened 2 months ago

Mojavve commented 2 months ago
OS: Arch Linux
WmG Version: Freshly downloaded repo
ffmpeg Version: n7.0.1
Freshly made venv

When encoding with vp8 or vp9 at an adjusted speed (I adjusted it to 0.5, with interpolation checked OFF ) the video that outputs is extremely low bitrate.

This result is extremely similar to what was experienced when the -psnr flag was initially updated here


1st pass: Ffmpeg command: ffmpeg -y -i tempVideoFiles/0_testmp4_4.799347826086956_7.790701394585724_c0a5150cb0_1724365552_0.mp4 -filter_complex_script tempVideoFiles/filters_6.txt -map [outvfinal] -pass 1 -passlogfile tempVideoFiles/encoder_6.log -shortest -copyts -start_at_zero -c:v libvpx-vp9 -c:a libopus -stats -pix_fmt yuv420p -threads 4 -auto-alt-ref 6 -lag-in-frames 25 -quality good -flags +psnr -row-mt 1 -tile-columns 2 -tile-rows 0 -arnr-maxframes 7 -arnr-strength 5 -aq-mode 0 -tune-content film -enable-tpl 1 -frame-parallel 0 -metadata Title=test WmG -b:v 10240000.0 -an -sn -f null /dev/null

2nd pass: Ffmpeg command: ffmpeg -y -i tempVideoFiles/0_testmp4_4.799347826086956_7.790701394585724_c0a5150cb0_1724365552_0.mp4 -filter_complex_script tempVideoFiles/filters_6.txt -map [outvfinal] -pass 2 -passlogfile tempVideoFiles/encoder_6.log -shortest -copyts -start_at_zero -c:v libvpx-vp9 -c:a libopus -stats -pix_fmt yuv420p -threads 4 -auto-alt-ref 6 -lag-in-frames 25 -speed 1 -quality good -flags +psnr -row-mt 1 -tile-columns 2 -tile-rows 0 -arnr-maxframes 7 -arnr-strength 5 -aq-mode 0 -tune-content film -enable-tpl 1 -frame-parallel 0 -metadata Title=test WmG -b:v 10240000.0 -an -sn tempVideoFiles/test_6.webm

filters_6.txt:

[0:v]tpad=stop=100:stop_mode=clone,trim=end=2.991353568498768[0vsc],[0vsc][0:a]concat=n=1:v=1:a=1[outvconcat][outaconcat],[outvconcat]setpts=2.0*PTS[outvpre],[outaconcat]atempo=0.5[outapre],[outvpre]null[outv],[outapre]anull[outa],[outv]null,null[outvfinal],[outa]anullsink

ffprobe test_6.webm:

ffprobe version n7.0.1 Copyright (c) 2007-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, matroska,webm, from 'test_6.webm':
  Metadata:
    title           : test WmG
    COMPATIBLE_BRANDS: isomiso2avc1mp41
    MAJOR_BRAND     : isom
    MINOR_VERSION   : 512
    ENCODER         : Lavf61.1.100
  Duration: 00:00:05.94, start: 0.000000, bitrate: 44 kb/s
  Stream #0:0: Video: vp9 (Profile 0), yuv420p(tv, bt709, progressive), 1920x1080, SAR 1:1 DAR 16:9, 14.99 fps, 14.99 tbr, 1k tbn
      Metadata:
        ENCODER         : Lavc61.3.100 libvpx-vp9
        DURATION        : 00:00:05.939000000
dfaker commented 2 months ago

Yeah this is a bug caused by using setpts with vp9 and vp8

https://trac.ffmpeg.org/ticket/11126

The previous workaround for this was able to remove setpts in most cases, in this one however it's central to the speed adjustment.