[FFmpeg-user] setpts filter produces much smaller files

George Welch george at grwelch.com
Wed May 21 14:44:20 EEST 2025


On 5/20/25 10:32 PM, Def Etienne wrote:
>> On 19 May 2025, at 03:01, George Welch via ffmpeg-user <ffmpeg-user at ffmpeg.org> wrote:
>>
>> Howdy ffmpeg users.
>>
>> I have found a behavior that seems strange to me.  The following two commands:
>>
>> $ ffmpeg -i input.mkv -an -c:v libx265 -preset slow -crf 21 output1.mkv
>>
>> and
>>
>> $ ffmpeg -i input.mkv -an -c:v libx265 -preset slow -crf 21 -vf "setpts=PTS-STARTPTS" output2.mkv
>>
>> produce output files that are very different.  The input file is 1080p h264 recorded at 15Mbps.  The output file in the first case is about 1.66 times larger than the second output file.  The video channel in the first case averages 7342 kbps while the video channel in the second case averages 4423 kbps.
>>
>> Unsurprisingly, dumping frames to png files and using imagemagick to compare them shows that the first output file has much higher fidelity to the original than the second.
>>
>> This is with ffmpeg 7.1.1 installed via homebrew on a fairly modern macbook pro.  Checking on a linux machine with a fairly old intel xeon processor (all I have access to) also with ffmpeg installed via homebrew produces nearly identical files.
>>
>> I wonder if this a bug in the mac version of ffmpeg?  I don't see why the setpts filter should produce a much lower bitrate, nor why it would be different under linux.
> The complete uncut console output in each case would have been a good starting point to explain the differences.
>
> Def


Happy to!

For the first case, with no filter:
george at austin:test2$ ffmpeg -i input.mkv -an -c:v libx265 -preset slow 
-crf 21 output1.mkv
ffmpeg version 7.1.1 Copyright (c) 2000-2025 the FFmpeg developers
   built with Apple clang version 15.0.0 (clang-1500.3.9.4)
   configuration: 
--prefix=/opt/homebrew/Cellar/ffmpeg/7.1.1-with-options_1 
--enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl 
--enable-libaom --enable-libdav1d --enable-libharfbuzz 
--enable-libmp3lame --enable-libopus --enable-libsnappy 
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 
--enable-libx265 --enable-libfontconfig --enable-libfreetype 
--enable-frei0r --enable-libass --enable-demuxer=dash --enable-neon 
--enable-opencl --enable-audiotoolbox --enable-videotoolbox 
--disable-htmlpages --enable-libfdk-aac --enable-nonfree
   libavutil      59. 39.100 / 59. 39.100
   libavcodec     61. 19.101 / 61. 19.101
   libavformat    61.  7.100 / 61.  7.100
   libavdevice    61.  3.100 / 61.  3.100
   libavfilter    10.  4.100 / 10.  4.100
   libswscale      8.  3.100 /  8.  3.100
   libswresample   5.  3.100 /  5.  3.100
   libpostproc    58.  3.100 / 58.  3.100
Input #0, matroska,webm, from 'input.mkv':
   Metadata:
     ENCODER         : Lavf61.1.100
   Duration: 00:00:10.00, start: 0.000000, bitrate: 15814 kb/s
   Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 
1920x1080, 30 fps, 30 tbr, 1k tbn
       Metadata:
         DURATION        : 00:00:10.000000000
   Stream #0:1: Audio: flac, 48000 Hz, stereo, s16
       Metadata:
         title           : Track1
         DURATION        : 00:00:09.984000000
Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 4.1+1-1d117be
x265 [info]: build info [Mac OS X][clang 16.0.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: NEON Neon_DotProd Neon_I8MM
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 12 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 3 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : star / 57 / 3 / 3
x265 [info]: Keyframe min / max / scenecut / bias  : 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 25 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 4 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-21.0 / 0.60
x265 [info]: tools: rect limit-modes rd=4 psy-rd=2.00 rdoq=2 psy-rdoq=1.00
x265 [info]: tools: rskip mode=1 signhide tmvp strong-intra-smoothing 
lslices=4
x265 [info]: tools: deblock sao
Output #0, matroska, to 'output1.mkv':
   Metadata:
     encoder         : Lavf61.7.100
   Stream #0:0: Video: hevc, yuv420p(tv, bt709, progressive), 1920x1080, 
q=2-31, 30 fps, 1k tbn
       Metadata:
         DURATION        : 00:00:10.000000000
         encoder         : Lavc61.19.101 libx265
       Side data:
         cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[out#0/matroska @ 0x600001d40000] video:8958KiB audio:0KiB subtitle:0KiB 
other streams:0KiB global headers:2KiB muxing overhead: 0.058398%
frame=  300 fps= 17 q=29.2 Lsize=    8963KiB time=00:00:09.93 
bitrate=7392.2kbits/s speed=0.562x
x265 [info]: frame I:      2, Avg QP:20.59  kb/s: 44433.72
x265 [info]: frame P:     70, Avg QP:22.11  kb/s: 20672.38
x265 [info]: frame B:    228, Avg QP:28.77  kb/s: 2918.24
x265 [info]: Weighted P-Frames: Y:2.9% UV:2.9%

encoded 300 frames in 17.65s (17.00 fps), 7337.64 kb/s, Avg QP:27.16

For the second case, with the setpts filter:
george at austin:test2$ ffmpeg -i input.mkv -an -c:v libx265 -preset slow 
-crf 21 -vf "setpts=PTS-STARTPTS" output2.mkv
ffmpeg version 7.1.1 Copyright (c) 2000-2025 the FFmpeg developers
   built with Apple clang version 15.0.0 (clang-1500.3.9.4)
   configuration: 
--prefix=/opt/homebrew/Cellar/ffmpeg/7.1.1-with-options_1 
--enable-shared --cc=clang --host-cflags= --host-ldflags= --enable-gpl 
--enable-libaom --enable-libdav1d --enable-libharfbuzz 
--enable-libmp3lame --enable-libopus --enable-libsnappy 
--enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 
--enable-libx265 --enable-libfontconfig --enable-libfreetype 
--enable-frei0r --enable-libass --enable-demuxer=dash --enable-neon 
--enable-opencl --enable-audiotoolbox --enable-videotoolbox 
--disable-htmlpages --enable-libfdk-aac --enable-nonfree
   libavutil      59. 39.100 / 59. 39.100
   libavcodec     61. 19.101 / 61. 19.101
   libavformat    61.  7.100 / 61.  7.100
   libavdevice    61.  3.100 / 61.  3.100
   libavfilter    10.  4.100 / 10.  4.100
   libswscale      8.  3.100 /  8.  3.100
   libswresample   5.  3.100 /  5.  3.100
   libpostproc    58.  3.100 / 58.  3.100
Input #0, matroska,webm, from 'input.mkv':
   Metadata:
     ENCODER         : Lavf61.1.100
   Duration: 00:00:10.00, start: 0.000000, bitrate: 15814 kb/s
   Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 
1920x1080, 30 fps, 30 tbr, 1k tbn
       Metadata:
         DURATION        : 00:00:10.000000000
   Stream #0:1: Audio: flac, 48000 Hz, stereo, s16
       Metadata:
         title           : Track1
         DURATION        : 00:00:09.984000000
Stream mapping:
   Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 4.1+1-1d117be
x265 [info]: build info [Mac OS X][clang 16.0.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: NEON Neon_DotProd Neon_I8MM
x265 [info]: Main profile, Level-6.1 (Main tier)
x265 [info]: Thread pool created using 12 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 3 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : star / 57 / 3 / 3
x265 [info]: Keyframe min / max / scenecut / bias  : 25 / 250 / 40 / 5.00
x265 [info]: Lookahead / bframes / badapt        : 25 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 4 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-21.0 / 0.60
x265 [info]: tools: rect limit-modes rd=4 psy-rd=2.00 rdoq=2 psy-rdoq=1.00
x265 [info]: tools: rskip mode=1 signhide tmvp strong-intra-smoothing 
lslices=4
x265 [info]: tools: deblock sao
Output #0, matroska, to 'output2.mkv':
   Metadata:
     encoder         : Lavf61.7.100
   Stream #0:0: Video: hevc, yuv420p(tv, bt709, progressive), 1920x1080, 
q=2-31, 1k tbn
       Metadata:
         DURATION        : 00:00:10.000000000
         encoder         : Lavc61.19.101 libx265
       Side data:
         cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[out#0/matroska @ 0x60000095c540] video:5377KiB audio:0KiB subtitle:0KiB 
other streams:0KiB global headers:2KiB muxing overhead: 0.096275%
frame=  300 fps= 19 q=33.8 Lsize=    5382KiB time=00:00:09.90 
bitrate=4453.7kbits/s speed=0.643x
x265 [info]: frame I:      2, Avg QP:24.75  kb/s: 1110316.00
x265 [info]: frame P:     70, Avg QP:26.52  kb/s: 405911.66
x265 [info]: frame B:    228, Avg QP:32.98  kb/s: 58793.19
x265 [info]: Weighted P-Frames: Y:2.9% UV:2.9%

encoded 300 frames in 15.36s (19.53 fps), 146797.66 kb/s, Avg QP:31.42

I can also post the input and output files on my cloud server if you 
want to try them.  However, I have tried several different input files 
and it does not seem to matter.

Thanks again,

--George


More information about the ffmpeg-user mailing list