filter_complex vs vf with one filter
What's the difference between "-filter_complex" and "-vf" when only one filter is used? Specially, when the "scale" filter is used. I assumed the results would be the same, but discovered the "-vf" version creates an mpeg2 file almost 80M larger for my ~600M input test file. $ ls -lGg TEST.mkv TEST-fc.mpg TEST-vf.mpg -rw-r--r--. 1 620992404 Nov 17 20:58 TEST.mkv -rw-r--r--. 1 578318336 Nov 17 21:02 TEST-fc.mpg -rw-r--r--. 1 660838400 Nov 17 21:06 TEST-vf.mpg But the video specs appear to be the same for both output files: $ for i in TEST-fc.mpg TEST-vf.mpg; do ffmpeg -i $i 2>&1 | egrep 'Input|Stream'; done Input #0, mpeg, from 'TEST-fc.mpg': Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 1711x720 [SAR 1:1 DAR 1711:720], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc Input #0, mpeg, from 'TEST-vf.mpg': Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p(tv, progressive), 1711x720 [SAR 1:1 DAR 1711:720], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc The TEST.mkv input file is only 10 mins of the video stream from the original 2hr file. The difference in size for the original (~9G) file is about 1G (7.4G for "-filter_complex" vs 8.4G for "-vf). Here's complete output for both 10 min TEST output files: $ ffmpeg -i TEST.mkv -codec:v mpeg2video -b:v 16384k -bufsize 4096k -maxrate 30000k -filter_complex 'scale=-1:720' -f vob TEST-fc.mpg ffmpeg version N-89089-g80bb81a Copyright (c) 2000-2017 the FFmpeg developers built with gcc 4.9.2 (GCC) 20150212 (Red Hat 4.9.2-6) configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libcdio --enable-libbluray --enable-openssl --disable-ffplay --disable-ffserver libavutil 56. 0.100 / 56. 0.100 libavcodec 58. 3.102 / 58. 3.102 libavformat 58. 2.100 / 58. 2.100 libavdevice 58. 0.100 / 58. 0.100 libavfilter 7. 0.101 / 7. 0.101 libswscale 5. 0.101 / 5. 0.101 libswresample 3. 0.101 / 3. 0.101 libpostproc 55. 0.100 / 55. 0.100 Input #0, matroska,webm, from 'TEST.mkv': Metadata: ENCODER : Lavf58.2.100 Duration: 00:10:00.23, start: 0.000000, bitrate: 8276 kb/s Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x808, SAR 1:1 DAR 240:101, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Metadata: DURATION : 00:10:00.225000000 Stream mapping: Stream #0:0 (h264) -> scale scale -> Stream #0:0 (mpeg2video) Press [q] to stop, [?] for help Output #0, vob, to 'TEST-fc.mpg': Metadata: encoder : Lavf58.2.100 Stream #0:0: Video: mpeg2video (Main), yuv420p, 1711x720 [SAR 172800:172811 DAR 240:101], q=2-31, 16384 kb/s, 23.98 fps, 90k tbn, 23.98 tbc (default) Metadata: encoder : Lavc58.3.102 mpeg2video Side data: cpb: bitrate max/min/avg: 30000000/0/16384000 buffer size: 4096000 vbv_delay: -1 frame=14391 fps= 74 q=2.0 Lsize= 564764kB time=00:10:00.14 bitrate=7709.1kbits/s dup=3 drop=0 speed=3.08x video:557904kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.229569% $ ffmpeg -i TEST.mkv -codec:v mpeg2video -b:v 16384k -bufsize 4096k -maxrate 30000k -vf 'scale=-1:720' -f vob TEST-vf.mpg ffmpeg version N-89089-g80bb81a Copyright (c) 2000-2017 the FFmpeg developers built with gcc 4.9.2 (GCC) 20150212 (Red Hat 4.9.2-6) configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libcdio --enable-libbluray --enable-openssl --disable-ffplay --disable-ffserver libavutil 56. 0.100 / 56. 0.100 libavcodec 58. 3.102 / 58. 3.102 libavformat 58. 2.100 / 58. 2.100 libavdevice 58. 0.100 / 58. 0.100 libavfilter 7. 0.101 / 7. 0.101 libswscale 5. 0.101 / 5. 0.101 libswresample 3. 0.101 / 3. 0.101 libpostproc 55. 0.100 / 55. 0.100 Input #0, matroska,webm, from 'TEST.mkv': Metadata: ENCODER : Lavf58.2.100 Duration: 00:10:00.23, start: 0.000000, bitrate: 8276 kb/s Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x808, SAR 1:1 DAR 240:101, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default) Metadata: DURATION : 00:10:00.225000000 Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native)) Press [q] to stop, [?] for help Output #0, vob, to 'TEST-vf.mpg': Metadata: encoder : Lavf58.2.100 Stream #0:0: Video: mpeg2video (Main), yuv420p, 1711x720 [SAR 172800:172811 DAR 240:101], q=2-31, 16384 kb/s, 23.98 fps, 90k tbn, 23.98 tbc (default) Metadata: DURATION : 00:10:00.225000000 encoder : Lavc58.3.102 mpeg2video Side data: cpb: bitrate max/min/avg: 30000000/0/16384000 buffer size: 4096000 vbv_delay: -1 frame=14391 fps= 68 q=2.0 Lsize= 645350kB time=00:10:00.14 bitrate=8809.1kbits/s dup=3 drop=0 speed=2.83x video:637531kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.226453%
On 11/18/2017 10:45 AM, Hans Carlson wrote:
What's the difference between "-filter_complex" and "-vf" when only one filter is used? Specially, when the "scale" filter is used.
This has come up before, and looks like it hasn't been fixed. In the filter_complex, the scale filter uses the bilinear method. In vf, the bicubic method. You can use 'scale=-1:720:flags=bicubic' in filter_complex to achieve the same result. Regards, Gyan
2017-11-18 6:33 GMT+01:00 Gyan Doshi <gyandoshi@gmail.com>:
On 11/18/2017 10:45 AM, Hans Carlson wrote:
What's the difference between "-filter_complex" and "-vf" when only one filter is used? Specially, when the "scale" filter is used.
This has come up before
Could you point me to the report? Thank you, Carl Eugen
On 11/18/2017 9:22 PM, Carl Eugen Hoyos wrote:
This has come up before
Could you point me to the report?
See this thread: https://ffmpeg.org/pipermail/ffmpeg-user/2017-May/036078.html Regards, Gyan
On Sat, 18 Nov 2017, Gyan Doshi wrote:
You can use 'scale=-1:720:flags=bicubic' in filter_complex to achieve the same result.
Thanks, that worked, but now the obvious question is which one is "better"... quality-wise? I'm not that concerned about the size difference, it was just an indication that something was different. So, of the possible algorithms (and there appear to be several): https://www.ffmpeg.org/ffmpeg-scaler.html#sws_005fflags any suggestions for which one gives the best quality? My application is mainly h264 -> mpeg2.
participants (3)
-
Carl Eugen Hoyos -
Gyan Doshi -
Hans Carlson