[FFmpeg-trac] #11126(ffmpeg:new): Filter "setpts=PTS-STARTPTS" in 2-pass VP9 may cause abnormal bitrate allocation
FFmpeg
trac at avcodec.org
Mon Aug 5 19:55:58 EEST 2024
#11126: Filter "setpts=PTS-STARTPTS" in 2-pass VP9 may cause abnormal bitrate
allocation
-------------------------------------+-------------------------------------
Reporter: Saul Baker | Owner: (none)
Type: defect | Status: new
Priority: normal | Component: ffmpeg
Version: git-master | Resolution:
Keywords: regression | Blocked By:
2-pass |
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Description changed by Saul Baker:
Old description:
> Summary of the bug:
>
> Converting an mp4 to vp9 webm displays a marked reduction in quality and
> small final video bitrate when the filter "setpts=PTS-STARTPTS" is
> applied during a 2 pass encode, 1 pass encodes do not display the same
> difference, nor does an arbitrary old version.
>
> How to reproduce:
> {{{
>
> ffmpeg -y -i "source.mp4" -filter_complex "setpts=PTS-STARTPTS" -pass 1
> -passlogfile pass.log -c:v libvpx-vp9 -c:a libopus -pix_fmt yuv420p
> -quality good -b:v 3271553 -an -sn -f null nul
> ffmpeg -y -i "source.mp4" -filter_complex "setpts=PTS-STARTPTS" -pass 2
> -passlogfile pass.log -c:v libvpx-vp9 -c:a libopus -pix_fmt yuv420p
> -quality good -b:v 3271553 -ac 1 -ar 48k -b:a 65536 -sn
> dest_2pass_setpts.webm
>
> ffmpeg -y -i "source.mp4" -filter_complex "null" -pass 1 -passlogfile
> pass.log -c:v libvpx-vp9 -c:a libopus -pix_fmt yuv420p -quality good
> -b:v 3271553 -an -sn -f null nul
> ffmpeg -y -i "source.mp4" -filter_complex "null" -pass 2 -passlogfile
> pass.log -c:v libvpx-vp9 -c:a libopus -pix_fmt yuv420p -quality good
> -b:v 3271553 -ac 1 -ar 48k -b:a 65536 -sn dest_2pass_nofilter.webm
>
> ffmpeg -y -i "source.mp4" -filter_complex "setpts=PTS-STARTPTS" -c:v
> libvpx-vp9 -c:a libopus -pix_fmt yuv420p -quality good -b:v 3271553
> -ac 1 -ar 48k -b:a 65536 -sn dest_1pass_setpts.webm
> }}}
>
> ffprobe output for 2024-08-01-git-bcf08c1171
> {{{
>
> >> ffprobe dest_2pass_setpts.webm
> Duration: 00:00:41.73, start: -0.007000, bitrate: 68 kb/s
>
> >> ffprobe dest_2pass_nofilter.webm
> Duration: 00:00:41.73, start: -0.007000, bitrate: 3268 kb/s
>
> >> ffprobe dest_1pass_setpts.webm
> Duration: N/A, start: -0.007000, bitrate: N/A
>
> }}}
>
> ffprobe output for 2023-01-30-git-2d202985b7
> {{{
>
> >> ffprobe dest_2pass_setpts.webm
> Duration: 00:00:41.73, start: -0.007000, bitrate: 3268 kb/s
>
> >> ffprobe dest_2pass_nofilter.webm
> Duration: 00:00:41.73, start: -0.007000, bitrate: 3268 kb/s
>
> >> ffprobe dest_1pass_setpts.webm
> Duration: 00:00:41.73, start: -0.007000, bitrate: 2614 kb/s
> }}}
>
>
> {{{
> ffmpeg version 2024-08-01-git-bcf08c1171-essentials_build-www.gyan.dev
> Copyright (c) 2000-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-zlib --enable-libsrt --enable-libssh --enable-
> libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264
> --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg
> --enable-libvpx --enable-mediafoundation --enable-libass --enable-
> libfreetype --enable-libfribidi --enable-libharfbuzz --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-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-
> libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm
> --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-
> libvorbis --enable-librubberband
> libavutil 59. 31.100 / 59. 31.100
> libavcodec 61. 11.100 / 61. 11.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
> }}}
>
>
> Patches should be submitted to the ffmpeg-devel mailing list and not this
> bug tracker.
New description:
Summary of the bug:
Converting an mp4 to vp9 webm displays a marked reduction in quality and
small final video bitrate when the filter "setpts=PTS-STARTPTS" is applied
during a 2 pass encode, 1 pass encodes do not display the same difference,
nor does an arbitrary old version.
How to reproduce:
{{{
ffmpeg -y -i "source.mp4" -filter_complex "[0:v]setpts=PTS-STARTPTS[outv]"
-map [outv] -pass 1 -passlogfile pass_setpts.log -c:v libvpx-vp9 -b:v
3271553 -an -sn -f null nul
ffmpeg -y -i "source.mp4" -filter_complex "[0:v]setpts=PTS-STARTPTS[outv]"
-map [outv] -pass 2 -passlogfile pass_setpts.log -c:v libvpx-vp9 -b:v
3271553 -an -sn dest_2pass_setpts.webm
ffmpeg -y -i "source.mp4" -filter_complex "[0:v]null[outv]" -map [outv]
-pass 1 -passlogfile pass_nofilter.log -c:v libvpx-vp9 -b:v 3271553 -an
-sn -f null nul
ffmpeg -y -i "source.mp4" -filter_complex "[0:v]null[outv]" -map [outv]
-pass 2 -passlogfile pass_nofilter.log -c:v libvpx-vp9 -b:v 3271553 -an
-sn dest_2pass_nofilter.webm
ffprobe -hide_banner -threads 0 -show_entries
"stream=time_base:format=size" -of "flat=h=0" dest_2pass_setpts.webm
ffprobe -hide_banner -threads 0 -show_entries
"stream=time_base:format=size" -of "flat=h=0" dest_2pass_nofilter.webm
}}}
ffprobe output
{{{
>> ffprobe -hide_banner -threads 0 -show_entries
"stream=time_base:format=size" -of "flat=h=0" dest_2pass_setpts.webm
Input #0, matroska,webm, from 'dest_2pass_setpts.webm':
Metadata:
COM.ANDROID.VERSION: 14
MAJOR_BRAND : mp42
MINOR_VERSION : 0
COMPATIBLE_BRANDS: isommp42
ENCODER : Lavf61.5.101
Duration: 00:00:41.57, start: 0.000000, bitrate: 65 kb/s
Stream #0:0: Video: vp9 (Profile 0), yuv420p(tv,
bt470bg/bt470bg/smpte170m, progressive), 846x480, SAR 1:1 DAR 141:80, 30
fps, 30 tbr, 1k tbn
Metadata:
ENCODER : Lavc61.11.100 libvpx-vp9
DURATION : 00:00:41.567000000
stream.0.time_base="1/1000"
format.size="338969"
>> ffprobe -hide_banner -threads 0 -show_entries
"stream=time_base:format=size" -of "flat=h=0" dest_2pass_nofilter.webm
Input #0, matroska,webm, from 'dest_2pass_nofilter.webm':
Metadata:
COM.ANDROID.VERSION: 14
MAJOR_BRAND : mp42
MINOR_VERSION : 0
COMPATIBLE_BRANDS: isommp42
ENCODER : Lavf61.5.101
Duration: 00:00:41.60, start: 0.000000, bitrate: 3275 kb/s
Stream #0:0: Video: vp9 (Profile 0), yuv420p(tv,
bt470bg/bt470bg/smpte170m, progressive), 846x480, SAR 1:1 DAR 141:80, 30
fps, 30 tbr, 1k tbn
Metadata:
ENCODER : Lavc61.11.100 libvpx-vp9
DURATION : 00:00:41.600000000
stream.0.time_base="1/1000"
format.size="17033515"
}}}
ffprobe output for 2024-08-01-git-bcf08c1171
{{{
>> ffprobe dest_2pass_setpts.webm
Duration: 00:00:41.73, start: -0.007000, bitrate: 68 kb/s
>> ffprobe dest_2pass_nofilter.webm
Duration: 00:00:41.73, start: -0.007000, bitrate: 3268 kb/s
>> ffprobe dest_1pass_setpts.webm
Duration: N/A, start: -0.007000, bitrate: N/A
}}}
ffprobe output for 2023-01-30-git-2d202985b7
{{{
>> ffprobe dest_2pass_setpts.webm
Duration: 00:00:41.73, start: -0.007000, bitrate: 3268 kb/s
>> ffprobe dest_2pass_nofilter.webm
Duration: 00:00:41.73, start: -0.007000, bitrate: 3268 kb/s
>> ffprobe dest_1pass_setpts.webm
Duration: 00:00:41.73, start: -0.007000, bitrate: 2614 kb/s
}}}
{{{
ffmpeg version 2024-08-01-git-bcf08c1171-essentials_build-www.gyan.dev
Copyright (c) 2000-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-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-
avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx
--enable-mediafoundation --enable-libass --enable-libfreetype --enable-
libfribidi --enable-libharfbuzz --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-libgme --enable-
libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-
libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-
amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-
librubberband
libavutil 59. 31.100 / 59. 31.100
libavcodec 61. 11.100 / 61. 11.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
}}}
Patches should be submitted to the ffmpeg-devel mailing list and not this
bug tracker.
--
--
Ticket URL: <https://trac.ffmpeg.org/ticket/11126#comment:8>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list