我正在尝试制作一个带有多个画中画(简称 PIP)的单个视频文件。我能够让两个画中画正常工作。我现在正在尝试添加第 4 个输入。
我希望它看起来像这样:
我尝试的命令:
ffmpeg -i 444_remote_0.webm -i 444_remote_1.webm -i 444_remote_2.webm \
-i 444_local_0.webm -filter_complex \
"[1:v]scale=iw/4:-1:flags=lanczos[rem1]; \
[2:v]scale=iw/4:-1:flags=lanczos[rem2]; \
[3:v]scale=iw/4:-1:flags=lanczos[loc0]; \
[0:v][loc0]overlay=main_w-overlay_w-10:main_h-overlay_h-10[bg]; \
[bg][rem1]overlay=main_w-overlay_w-180:main_h-overlay_h-10[v]; \
[bg][rem2]overlay=main_w-overlay_w-360:main_h-overlay_h-10[v]; \
[0:a][1:a][2:a][3:a]amerge=inputs=4[a]" \
-map "[v]" -map "[a]" -ac 2 -ar 44100 -vcodec libx264 -acodec aac 444.mp4
我收到一个新错误:Invalid stream specifier: bg.
控制台输出:
ffmpeg -i 444_remote_0.webm -i 444_remote_1.webm -i 444_remote_2.webm -i 444_local_0.webm -filter_complex "[1:v]scale=iw/4:-1:flags=lanczos[rem1]; [2:v]scale=iw/4:-1:flags=lanczos[rem2]; [3:v]scale=iw/4:-1:flags=lanczos[loc0]; [0:v][loc0]overlay=main_w-overlay_w-10:main_h-overlay_h-10[bg]; [bg][rem1]overlay=main_w-overlay_w-180:main_h-overlay_h-10[v]; [bg][rem2]overlay=main_w-overlay_w-360:main_h-overlay_h-10[v]; [0:a][1:a][2:a][3:a]amerge=inputs=4[a]" -map "[v]" -map "[a]" -ac 2 -ar 44100 -vcodec libx264 -acodec aac 444.mp4
ffmpeg version N-80901-gfebc862 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
libavutil 55. 28.100 / 55. 28.100
libavcodec 57. 48.101 / 57. 48.101
libavformat 57. 41.100 / 57. 41.100
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 47.100 / 6. 47.100
libavresample 3. 0. 0 / 3. 0. 0
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 1.100 / 2. 1.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from '444_remote_0.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream #0:1(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Input #1, matroska,webm, from '444_remote_1.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #1:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream #1:1(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Input #2, matroska,webm, from '444_remote_2.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #2:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream #2:1(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
Input #3, matroska,webm, from '444_local_0.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #3:0(eng): Audio: opus, 48000 Hz, mono, fltp (default)
Stream #3:1(eng): Video: vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
[matroska,webm @ 0x35f5c40] Invalid stream specifier: bg.
Last message repeated 1 times
Stream specifier 'bg' in filtergraph description [1:v]scale=iw/4:-1:flags=lanczos[rem1]; [2:v]scale=iw/4:-1:flags=lanczos[rem2]; [3:v]scale=iw/4:-1:flags=lanczos[loc0]; [0:v][loc0]overlay=main_w-overlay_w-10:main_h-overlay_h-10[bg]; [bg][rem1]overlay=main_w-overlay_w-180:main_h-overlay_h-10[v]; [bg][rem2]overlay=main_w-overlay_w-360:main_h-overlay_h-10[v]; [0:a][1:a][2:a][3:a]amerge=inputs=4[a] matches no streams.
答案1
放置选项 1:悬挂在右侧
就像您的模型一样,其中点的权重位于右侧:
ffmpeg -i blue.webm -i green.webm -i red.webm -i orange.webm -filter_complex \
"[1:v]scale=iw/4:-1:flags=lanczos[pip1]; \
[2:v]scale=iw/4:-1:flags=lanczos[pip2]; \
[3:v]scale=iw/4:-1:flags=lanczos[pip3]; \
[0:v][pip1]overlay=main_w-overlay_w-10:main_h-overlay_h-10[bg1]; \
[bg1][pip2]overlay=main_w-overlay_w*2-20:main_h-overlay_h-10[bg2]; \
[bg2][pip3]overlay=main_w-overlay_w*3-30:main_h-overlay_h-10,format=yuv420p[v]; \
[0:a][1:a][2:a][3:a]amerge=inputs=4[a]" \
-map "[v]" -map "[a]" -ac 1 output.mp4
放置选项 2:居中
ffmpeg -i blue.webm -i green.webm -i red.webm -i orange.webm -filter_complex \
"[1:v]scale=iw/4:-1:flags=lanczos[pip1]; \
[2:v]scale=iw/4:-1:flags=lanczos[pip2]; \
[3:v]scale=iw/4:-1:flags=lanczos[pip3]; \
[0:v][pip1]overlay=main_w-overlay_w-10:main_h-overlay_h-10[bg1]; \
[bg1][pip2]overlay=(main_w-overlay_w)/2:main_h-overlay_h-10[bg2]; \
[bg2][pip3]overlay=10:main_h-overlay_h-10,format=yuv420p[v]; \
[0:a][1:a][2:a][3:a]amerge=inputs=4[a]" \
-map "[v]" -map "[a]" -ac 1 output.mp4