[FFmpeg-user] Two video streams generated with map, filter_complex, scale
Hans Carlson
forbyta at gmx.com
Sat Jun 21 02:23:02 EEST 2025
Was there a change in behavior with regards to the interaction between
map, filter_complex and scale at some point between 4.4.2 and 6.1.2?
To be more precise... The following command using 6.1.2 generates output
with 2 video streams; one for the original (1920x1080) and one for the
scaled (1280x720):
FFMPEG (6.1.2)
ffmpeg -f lavfi -i color=black:s=1920x1080 -map 0:0 -codec h264 -filter_complex "scale=width=-1:height=720" -t 10 -f null /dev/null
Stream #0:0: Video: h264, yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbn (default)
Stream #0:1: Video: h264, yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbn
All of the following variations using both 6.1.2 and 4.4.2 only generate a
single video stream - the scaled (1280x720):
FFMPEG (6.1.2)
ffmpeg -f lavfi -i color=black:s=1920x1080 -codec h264 -vf "scale=width=-1:height=720" -t 10 -f null /dev/null
ffmpeg -f lavfi -i color=black:s=1920x1080 -map 0:0 -codec h264 -vf "scale=width=-1:height=720" -t 10 -f null /dev/null
ffmpeg -f lavfi -i color=black:s=1920x1080 -codec h264 -filter_complex "scale=width=-1:height=720" -t 10 -f null /dev/null
Stream #0:0: Video: h264, yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbn
FFMPEG (4.4.2)
ffmpeg -f lavfi -i color=black:s=1920x1080 -map 0:0 -codec h264 -filter_complex "scale=width=-1:height=720" -t 10 -f null /dev/null
ffmpeg -f lavfi -i color=black:s=1920x1080 -codec h264 -filter_complex "scale=width=-1:height=720" -t 10 -f null /dev/null
ffmpeg -f lavfi -i color=black:s=1920x1080 -map 0:0 -codec h264 -vf "scale=width=-1:height=720" -t 10 -f null /dev/null
ffmpeg -f lavfi -i color=black:s=1920x1080 -codec h264 -vf "scale=width=-1:height=720" -t 10 -f null /dev/null
Stream #0:0: Video: h264, yuv420p(tv, progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbn
As you can see, using -vf with or without -map works with both 6.1.2 and
4.4.2. Using -filter_complex with or without -map works with 4.4.2, but
-filter_complex using 6.1.2 only works if -map is NOT used.
I've included full verbose output below for the 6.1.2 and 4.4.2 case that
uses map and filter_complex.
I realize I'm not using the latest version of ffmpeg (6.1.2 is the latest
from my distro and I'm not currently setup to compile my own version), so
if this WAS a bug in 6.1.2 that's been fixed in a later release, please
let me know. Otherwise, just trying to understand if this is still a bug,
-OR- was a bug in 4.4.2 and fixed as of 6.1.2 resulting in an intentional
change in the way map/filter_complex behaves -OR- something else.
Thanks.
---------------------------------------------------------------------------------------------------
FFMPEG 6.1.2
$ ffmpeg -loglevel verbose -f lavfi -i color=black:s=1920x1080 -map 0:0 -codec h264 -filter_complex "scale=width=-1:height=720" -t 10 -f null /dev/null
ffmpeg version 6.1.2 Copyright (c) 2000-2024 the FFmpeg developers
built with gcc 14 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-lcms2 --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcodec2 --enable-libcdio --enable-libdrm --enable-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-libplacebo --enable-librsvg --enable-librav1e --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libvpl --enable-runtime-cpudetect
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
libpostproc 57. 3.100 / 57. 3.100
[Parsed_scale_0 @ 0x55a230a96f00] w:-1 h:720 flags:'' interl:0
[Parsed_color_0 @ 0x55a230a96f00] size:1920x1080 rate:25/1 duration:-1.000000 sar:1/1
Input #0, lavfi, from 'color=black:s=1920x1080':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: wrapped_avframe, 1 reference frame, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn
[out#0/null @ 0x55a230a9f400] Creating output stream from unlabeled output of complex filtergraph 0.
[vost#0:0 @ 0x55a230a9fdc0] Matched encoder 'libx264' for codec 'h264'.
[vost#0:0/libx264 @ 0x55a230a9fdc0] Created video stream from complex filtergraph 0:[scale:default]
[vost#0:0/libx264 @ 0x55a230a9fdc0]
[out#0/null @ 0x55a230a9f400] Adding streams from explicit maps...
[vost#0:1 @ 0x55a230aa1900] Matched encoder 'libx264' for codec 'h264'.
[vost#0:1/libx264 @ 0x55a230aa1900] Created video stream from input stream 0:0
Stream mapping:
Stream #0:0 (wrapped_avframe) -> scale:default (graph 0)
scale:default (graph 0) -> Stream #0:0 (libx264)
Stream #0:0 -> #0:1 (wrapped_avframe (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[Parsed_scale_0 @ 0x55a230aa4040] w:-1 h:720 flags:'' interl:0
[graph 0 input from stream 0:0 @ 0x55a230ab4540] w:1920 h:1080 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1
[Parsed_scale_0 @ 0x55a230aa4040] w:1920 h:1080 fmt:yuv420p sar:1/1 -> w:1280 h:720 fmt:yuv420p sar:1/1 flags:0x00000004
[graph 1 input from stream 0:0 @ 0x55a230e67000] w:1920 h:1080 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1
[libx264 @ 0x55a230aa01c0] using SAR=1/1
[libx264 @ 0x55a230aa01c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55a230aa01c0] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x55a230aa1d00] using SAR=1/1
[libx264 @ 0x55a230aa1d00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55a230aa1d00] profile High, level 4.0, 4:2:0, 8-bit
Output #0, null, to '/dev/null':
Metadata:
encoder : Lavf60.16.100
Stream #0:0: Video: h264, 1 reference frame, yuv420p(tv, progressive), 1280x720 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbn (default)
Metadata:
encoder : Lavc60.31.102 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Stream #0:1: Video: h264, 1 reference frame, yuv420p(progressive), 1920x1080 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbn
Metadata:
encoder : Lavc60.31.102 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
No more output streams to write to, finishing.e=00:00:05.72 bitrate=N/A speed=5.68x
[vist#0:0/wrapped_avframe @ 0x55a230a9e180] Decoder thread received EOF packet
[vist#0:0/wrapped_avframe @ 0x55a230a9e180] Decoder returned EOF, finishing
[vist#0:0/wrapped_avframe @ 0x55a230a9e180] Terminating decoder thread
[out#0/null @ 0x55a230a9f400] All streams finished
[out#0/null @ 0x55a230a9f400] Terminating muxer thread
[out#0/null @ 0x55a230a9f400] Output file #0 (/dev/null):
[out#0/null @ 0x55a230a9f400] Output stream #0:0 (video): 250 frames encoded; 250 packets muxed (10839 bytes);
[out#0/null @ 0x55a230a9f400] Output stream #0:1 (video): 250 frames encoded; 250 packets muxed (18773 bytes);
[out#0/null @ 0x55a230a9f400] Total: 500 packets (29612 bytes) muxed
[out#0/null @ 0x55a230a9f400] video:29kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
frame= 250 fps=191 q=-1.0 Lq=-1.0 size=N/A time=00:00:09.88 bitrate=N/A speed=7.54x
[libx264 @ 0x55a230aa01c0] frame I:1 Avg QP: 9.00 size: 944
[libx264 @ 0x55a230aa01c0] frame P:63 Avg QP: 9.14 size: 46
[libx264 @ 0x55a230aa01c0] frame B:186 Avg QP:12.67 size: 38
[libx264 @ 0x55a230aa01c0] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 @ 0x55a230aa01c0] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x55a230aa01c0] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x55a230aa01c0] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0%
[libx264 @ 0x55a230aa01c0] 8x8 transform intra:0.0%
[libx264 @ 0x55a230aa01c0] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x55a230aa01c0] i16 v,h,dc,p: 98% 0% 2% 0%
[libx264 @ 0x55a230aa01c0] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0x55a230aa01c0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55a230aa01c0] kb/s:8.67
[libx264 @ 0x55a230aa1d00] frame I:1 Avg QP: 9.00 size: 1159
[libx264 @ 0x55a230aa1d00] frame P:63 Avg QP: 9.14 size: 77
[libx264 @ 0x55a230aa1d00] frame B:186 Avg QP:12.67 size: 69
[libx264 @ 0x55a230aa1d00] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 @ 0x55a230aa1d00] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x55a230aa1d00] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x55a230aa1d00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0%
[libx264 @ 0x55a230aa1d00] 8x8 transform intra:0.0%
[libx264 @ 0x55a230aa1d00] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x55a230aa1d00] i16 v,h,dc,p: 99% 0% 1% 0%
[libx264 @ 0x55a230aa1d00] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0x55a230aa1d00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x55a230aa1d00] kb/s:15.02
[in#0/lavfi @ 0x55a230a97200] Terminating demuxer thread
[in#0/lavfi @ 0x55a230a97200] Input file #0 (color=black:s=1920x1080):
[in#0/lavfi @ 0x55a230a97200] Input stream #0:0 (video): 253 packets read (121440 bytes); 251 frames decoded; 0 decode errors;
[in#0/lavfi @ 0x55a230a97200] Total: 253 packets (121440 bytes) demuxed
---------------------------------------------------------------------------------------------------
FFMPEG 4.4.2
$ ffmpeg -loglevel verbose -f lavfi -i color=black:s=1920x1080 -map 0:0 -codec h264 -filter_complex "scale=width=-1:height=720" -t 10 -f null /dev/null
ffmpeg version 4.4.2 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (GCC)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librav1e --enable-librtmp --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libglslang --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-avresample --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
[Parsed_color_0 @ 0x56397f3575c0] size:1920x1080 rate:25/1 duration:-1.000000 sar:1/1
Input #0, lavfi, from 'color=black:s=1920x1080':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
[Parsed_scale_0 @ 0x56397f35d400] w:-1 h:720 flags:'bilinear' interl:0
Matched encoder 'libx264' for codec 'h264'.
Stream mapping:
Stream #0:0 (rawvideo) -> scale
scale -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[Parsed_scale_0 @ 0x56397f366c00] w:-1 h:720 flags:'bilinear' interl:0
[graph 0 input from stream 0:0 @ 0x56397f367c00] w:1920 h:1080 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1
[Parsed_scale_0 @ 0x56397f366c00] w:1920 h:1080 fmt:yuv420p sar:1/1 -> w:1280 h:720 fmt:yuv420p sar:1/1 flags:0x2
[libx264 @ 0x56397f35fb00] using SAR=1/1
[libx264 @ 0x56397f35fb00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x56397f35fb00] profile High, level 3.1, 4:2:0, 8-bit
Output #0, null, to '/dev/null':
Metadata:
encoder : Lavf58.76.100
Stream #0:0: Video: h264, 1 reference frame, yuv420p(tv, progressive), 1280x720 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbn
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 1 fps=0.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A speed= 0x frame= 95 fps=0.0 q=28.0 size=N/A time=00:00:01.72 bitrate=N/A speed=3.41x frame= 196 fps=194 q=28.0 size=N/A time=00:00:05.76 bitrate=N/A speed=5.71x No more output streams to write to, finishing.
frame= 250 fps=178 q=-1.0 Lsize=N/A time=00:00:09.92 bitrate=N/A speed=7.07x
video:11kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Input file #0 (color=black:s=1920x1080):
Input stream #0:0 (video): 251 packets read (780710400 bytes); 251 frames decoded;
Total: 251 packets (780710400 bytes) demuxed
Output file #0 (/dev/null):
Output stream #0:0 (video): 250 frames encoded; 250 packets muxed (10838 bytes);
Total: 250 packets (10838 bytes) muxed
[libx264 @ 0x56397f35fb00] frame I:1 Avg QP: 9.00 size: 943
[libx264 @ 0x56397f35fb00] frame P:63 Avg QP: 9.14 size: 46
[libx264 @ 0x56397f35fb00] frame B:186 Avg QP:12.67 size: 38
[libx264 @ 0x56397f35fb00] consecutive B-frames: 0.8% 0.0% 0.0% 99.2%
[libx264 @ 0x56397f35fb00] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x56397f35fb00] mb P I16..4: 0.0% 0.0% 0.0% P16..4: 0.0% 0.0% 0.0% 0.0% 0.0% skip:100.0%
[libx264 @ 0x56397f35fb00] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.0% 0.0% 0.0% direct: 0.0% skip:100.0%
[libx264 @ 0x56397f35fb00] 8x8 transform intra:0.0%
[libx264 @ 0x56397f35fb00] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x56397f35fb00] i16 v,h,dc,p: 98% 0% 2% 0%
[libx264 @ 0x56397f35fb00] i8c dc,h,v,p: 100% 0% 0% 0%
[libx264 @ 0x56397f35fb00] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x56397f35fb00] kb/s:8.67
More information about the ffmpeg-user
mailing list