如何使用NReco ffmpeg ConvertMedia或只是ffmpeg命令行组合2个视频
本文关键字:ffmpeg 组合 命令行 2个 视频 何使用 NReco ConvertMedia | 更新日期: 2023-09-27 18:11:31
我们有两个视频:video1。Webm和video . Webm。如何将这两者结合起来并得到包含来自video1的视频的output.mp4。来自video1和video2的Webm和音频?
的例子:
video1(audio1 in video1) + video2(audio2 in video2) = outputVideo(video1 + audio1 +audio2)
图像示例
ffmpeg -i 1。Webm - 2.webm版权所有(c) 2000-2016 ffmpeg开发者使用gcc 5.4.0 (gcc)构建配置:——enable-gpl——enable-version3——disable-w32threads——enable-dxva2——enable-libmfx——enable-nvenc——enable-avisynth——enable-bzlib——enable-libebur128——enable-fontconfig——enable-frei0r——enable-gnutls——enable-iconv——enable-libass——enable-libbluray——enable-libbs2b——enable-libcaca——enable-libfreetype——enable-libgme——enable-libgsm——enable-libilbc——enable-libmodplug——enable-libmp3lame——enable-libopencore-amrnb——enable-libopencore-amrwb——enable-libopenh264——enable-libopenjpeg——enable-libopus——enable-librtmp——enable-libschroedinger——enable-libsnappy——enable-libsoxr——enable-libspeex——enable-libtheora——enable-libtwolame——enable-libvidstab——enable-libvo-amrwbenc——enable-libvorbis——enable-libvpx——enable-libwavpack——enable-libwebp——enable-libx264——enable-libx265——enable-libxavs——enable-libxvid——enable-libzimg——enable-lzma——enable-decklink——enable-zliblibavutil 55。32.100/55。32.100libavcodec 57。60.101/57。60.101libavformat 57。51.102/57。51.102libavdevice 57。0.102/57。0.102libavfilter 6。63.100/6。63.100libswscale 4。1.100/4。1.100libswresample 2。2.100/2。2.100libpostproc 54。0.100/54。0.100输入#0,matroska,webm,来自'1.webm':元数据:编码器:libwebm-0.2.1.0creation_time: 2016-10-05T07:54:05.064000Z持续时间:00:00:30.11,起始时间:0.000000,比特率:798 kb/s流#0:0(eng):音频:opus, 48000 Hz,单声道,fltp(默认)视频:vp8, yuv420p, 640x480, SAR 1:1, DAR 4:3, 8.33 tbr, 1k tbn, 1k tbc(默认)输入#1,matroska,webm,来自'2.webm':元数据:编码器:libwebm-0.2.1.0creation_time: 2016-10-05T07:54:20.135000Z持续时间:00:00:30.20,起始时间:0.000000,比特率:523kb/s流#1:0(eng):音频:opus, 48000 Hz,单声道,fltp(默认)流#1:1(eng):视频:vp8, yuv420p, 640x480, SAR 1:1 DAR 4:3, 1k tbr, 1k tbn, 1k tbc(默认)必须指定至少一个输出文件。
视频2和视频1没有声音,但非常糟糕。转换长。
>ffmpeg -i 1.webm -i 2.webm -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map 0:v -map "[a]" -ac 2 -shortest output.webm
ffmpeg version N-81872-gbe1d324 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 32.100 / 55. 32.100
libavcodec 57. 60.101 / 57. 60.101
libavformat 57. 51.102 / 57. 51.102
libavdevice 57. 0.102 / 57. 0.102
libavfilter 6. 63.100 / 6. 63.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 2.100 / 2. 2.100
libpostproc 54. 0.100 / 54. 0.100
Input #0, matroska,webm, from '1.webm':
Metadata:
encoder : libwebm-0.2.1.0
creation_time : 2016-10-05T07:54:05.064000Z
Duration: 00:00:30.11, start: 0.000000, bitrate: 798 kb/s
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, 8.33 tbr, 1k tbn, 1k tbc (default)
Input #1, matroska,webm, from '2.webm':
Metadata:
encoder : libwebm-0.2.1.0
creation_time : 2016-10-05T07:54:20.135000Z
Duration: 00:00:30.20, start: 0.000000, bitrate: 523 kb/s
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, 1k tbr, 1k tbn, 1k tbc (default)
[Parsed_amerge_0 @ 00000000026d4400] No channel layout for input 1
[Parsed_amerge_0 @ 00000000026d4400] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
[libvpx-vp9 @ 0000000002592280] v1.6.0
[libopus @ 00000000024d81e0] No bit rate set. Defaulting to 96000 bps.
Output #0, webm, to 'output.webm':
Metadata:
encoder : Lavf57.51.102
Stream #0:0(eng): Video: vp9 (libvpx-vp9), yuv420p, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 200 kb/s, 8.33 fps, 1k tbn, 8.33 tbc (default)
Metadata:
encoder : Lavc57.60.101 libvpx-vp9
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: opus (libopus), 48000 Hz, stereo, flt, 96 kb/s (default)
Metadata:
encoder : Lavc57.60.101 libopus
Stream mapping:
Stream #0:0 (opus) -> amerge:in0 (graph 0)
Stream #1:0 (opus) -> amerge:in1 (graph 0)
Stream #0:1 -> #0:0 (vp8 (native) -> vp9 (libvpx-vp9))
amerge (graph 0) -> Stream #0:1 (libopus)
Press [q] to stop, [?] for help
Error while decoding stream #0:0: Cannot allocate memory94 bitrate= 91.8kbits/s speed=2.33x
Last message repeated 4 times
Error while decoding stream #0:0: Cannot allocate memory94 bitrate= 100.0kbits/s speed=1.62x
Last message repeated 23 times
Error while decoding stream #0:0: Cannot allocate memory94 bitrate= 133.1kbits/s speed=1.27x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory94 bitrate= 160.5kbits/s speed=1.06x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory94 bitrate= 164.1kbits/s speed=0.932x
Last message repeated 23 times
Error while decoding stream #0:0: Cannot allocate memory94 bitrate= 185.8kbits/s speed=0.819x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory94 bitrate= 212.5kbits/s speed=0.72x
Last message repeated 4 times
Error while decoding stream #0:0: Cannot allocate memory28 bitrate= 242.0kbits/s speed=0.68x
Last message repeated 18 times
Error while decoding stream #0:0: Cannot allocate memory50 bitrate= 190.1kbits/s speed= 0.9x
Last message repeated 13 times
Error while decoding stream #0:0: Cannot allocate memory50 bitrate= 205.9kbits/s speed=0.849x
Last message repeated 21 times
Error while decoding stream #0:0: Cannot allocate memory50 bitrate= 209.5kbits/s speed=0.781x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory50 bitrate= 225.2kbits/s speed=0.741x
Last message repeated 16 times
Error while decoding stream #0:0: Cannot allocate memory50 bitrate= 240.9kbits/s speed=0.695x
Last message repeated 18 times
Error while decoding stream #0:0: Cannot allocate memory68 bitrate= 239.9kbits/s speed=0.665x
Error while decoding stream #0:0: Cannot allocate memory76 bitrate= 251.1kbits/s speed=0.659x
Last message repeated 10 times
Error while decoding stream #0:0: Cannot allocate memory99 bitrate= 211.2kbits/s speed=0.791x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory99 bitrate= 212.8kbits/s speed=0.751x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory99 bitrate= 224.7kbits/s speed=0.724x
Last message repeated 11 times
Error while decoding stream #0:0: Cannot allocate memory99 bitrate= 225.4kbits/s speed=0.701x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory99 bitrate= 235.8kbits/s speed=0.678x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory99 bitrate= 244.0kbits/s speed=0.654x
Last message repeated 12 times
Error while decoding stream #0:0: Cannot allocate memory16 bitrate= 242.8kbits/s speed=0.645x
Last message repeated 1 times
Error while decoding stream #0:0: Cannot allocate memory00 bitrate= 242.9kbits/s speed=0.638x
Error while decoding stream #0:0: Cannot allocate memory36 bitrate= 246.9kbits/s speed=0.639x
Last message repeated 8 times
Error while decoding stream #0:0: Cannot allocate memory46 bitrate= 218.2kbits/s speed=0.727x
Last message repeated 16 times
Error while decoding stream #0:0: Cannot allocate memory46 bitrate= 219.9kbits/s speed=0.707x
Last message repeated 11 times
Error while decoding stream #0:0: Cannot allocate memory46 bitrate= 227.5kbits/s speed=0.69x
Last message repeated 18 times
Error while decoding stream #0:0: Cannot allocate memory46 bitrate= 229.6kbits/s speed=0.673x
Last message repeated 11 times
Error while decoding stream #0:0: Cannot allocate memory46 bitrate= 237.3kbits/s speed=0.657x
Last message repeated 16 times
Error while decoding stream #0:0: Cannot allocate memory46 bitrate= 238.8kbits/s speed=0.642x
Last message repeated 11 times
Error while decoding stream #0:0: Cannot allocate memory46 bitrate= 245.4kbits/s speed=0.627x
Last message repeated 9 times
Error while decoding stream #0:0: Cannot allocate memory76 bitrate= 242.9kbits/s speed=0.625x
Last message repeated 1 times
Error while decoding stream #0:0: Cannot allocate memory60 bitrate= 246.0kbits/s speed=0.618x
Error while decoding stream #0:0: Cannot allocate memory97 bitrate= 229.5kbits/s speed=0.697x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory97 bitrate= 235.1kbits/s speed=0.679x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory97 bitrate= 236.4kbits/s speed=0.664x
Last message repeated 11 times
Error while decoding stream #0:0: Cannot allocate memory97 bitrate= 241.4kbits/s speed=0.652x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory97 bitrate= 242.8kbits/s speed=0.639x
Last message repeated 11 times
Error while decoding stream #0:0: Cannot allocate memory97 bitrate= 247.9kbits/s speed=0.627x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory97 bitrate= 249.4kbits/s speed=0.616x
Last message repeated 8 times
Error while decoding stream #0:0: Cannot allocate memory24 bitrate= 252.4kbits/s speed=0.611x
Last message repeated 4 times
Error while decoding stream #0:0: Cannot allocate memory96 bitrate= 253.9kbits/s speed=0.612x
Error while decoding stream #0:0: Cannot allocate memory32 bitrate= 252.1kbits/s speed=0.611x
Last message repeated 15 times
Error while decoding stream #0:0: Cannot allocate memory45 bitrate= 233.6kbits/s speed=0.663x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory45 bitrate= 239.7kbits/s speed=0.652x
Last message repeated 17 times
Error while decoding stream #0:0: Cannot allocate memory45 bitrate= 245.3kbits/s speed=0.641x
Last message repeated 23 times
Error while decoding stream #0:0: Cannot allocate memory45 bitrate= 246.6kbits/s speed=0.629x
Last message repeated 25 times
Error while decoding stream #0:0: Cannot allocate memory60 bitrate= 251.4kbits/s speed=0.621x
Last message repeated 8 times
Error while decoding stream #0:0: Cannot allocate memory80 bitrate= 254.7kbits/s speed=0.629x
Last message repeated 18 times
Error while decoding stream #0:0: Cannot allocate memory93 bitrate= 239.0kbits/s speed=0.676x
Last message repeated 29 times
Error while decoding stream #0:0: Cannot allocate memory93 bitrate= 243.4kbits/s speed=0.663x
Last message repeated 21 times
Error while decoding stream #0:0: Cannot allocate memory93 bitrate= 247.8kbits/s speed=0.655x
Last message repeated 13 times
Error while decoding stream #0:0: Cannot allocate memory93 bitrate= 252.1kbits/s speed=0.644x
Last message repeated 15 times
Error while decoding stream #0:0: Cannot allocate memory17 bitrate= 251.6kbits/s speed=0.642x
Last message repeated 4 times
Error while decoding stream #0:0: Cannot allocate memory44 bitrate= 253.6kbits/s speed=0.64x
Last message repeated 4 times
Error while decoding stream #0:0: Cannot allocate memory40 bitrate= 254.2kbits/s speed=0.644x
Last message repeated 5 times
frame= 249 fps=5.4 q=0.0 Lsize= 946kB time=00:00:30.12 bitrate= 257.2kbits/s speed=0.654x
video:806kB audio:133kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.632650%
使用amerge将两个音频输入合并成一个输出流,然后选择您想要的-map
:
ffmpeg -i video0 -i video1 -filter_complex "[0:a][1:a]amerge=inputs=2[a]" -map 0:v -map "[a]" -ac 2 -shortest output
amerge默认是
inputs=2
,但我还是添加了它,因为我经常看到用户认为它是自动的,当他们试图合并两个以上的流两个输入都是单声道,因此合并将产生立体声输出。这使得我添加的
-ac 2
变得多余,但我还是添加了它,以防你想合并两个立体声输入。否则,amerge将使Opus不支持的4通道输出,或者至少编码器不支持;如果你得到
Cannot allocate memory
添加一个:"[0:a]afifo[af];[af][1:a]amerge=inputs=2[a]"
或试试amix:
"[0:a][1:a]amix=inputs=2:duration=shortest[a]"