ffmpeg newbie在这里努力做一些显然应该很容易的事情。
我想连接三个视频,其中一个只是一个空白视频两秒过渡。
首先我用以下内容生成空白视频:
ffmpeg -f lavfi -i color=c=black:s=320x240:d=0.5 silent.mp4
在我尝试将其与其他两个视频连接起来之后:
ffmpeg -i video-a.mp4 -i 2-seconds-silent-video.mp4 -i video-b.mp4 -y -filter_complex concat=n=3:v=1:a=1 result.mp4
我得到了什么:
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libvpx --enable-libfdk-aac --enable-libx265 --enable-nonfree --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video-a.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:03.03, start: 0.033333, bitrate: 822 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 691 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '2-seconds-silent-video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:02.00, start: 0.000000, bitrate: 17 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 11 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'video-b.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf56.40.101
Duration: 00:00:03.03, start: 0.033333, bitrate: 745 kb/s
Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 613 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
Metadata:
handler_name : SoundHandler
Cannot find a matching stream for unlabeled input pad 5 on filter Parsed_concat_0
我也尝试过没有成功:
ffmpeg -y -i "concat:video-a.mp4|2-seconds-silent-video.mp4|video-b.mp4" -c copy result.mp4
结果:
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-libvpx --enable-libfdk-aac --enable-libx265 --enable-nonfree --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fd12a812800] Found duplicated MOOV Atom. Skipped it
Last message repeated 1 times
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'concat:video-a.mp4|2-seconds-silent-video.mp4|video-b.mp4':
Metadata:
encoder : Lavf56.40.101
minor_version : 512
major_brand : isom
compatible_brands: isomiso2avc1mp41
Duration: 00:00:03.03, start: 0.033333, bitrate: 1579 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 691 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
[mp4 @ 0x7fd12a033a00] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x7fd12a033a00] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, mp4, to 'result.mp4':
Metadata:
compatible_brands: isomiso2avc1mp41
minor_version : 512
major_brand : isom
encoder : Lavf56.36.100
Stream #0:0(und): Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 691 kb/s, 25 fps, 25 tbr, 12800 tbn, 12800 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 75 fps=0.0 q=-1.0 Lsize= 305kB time=00:00:03.05 bitrate= 818.1kbits/s
video:253kB audio:48kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.179313%
答案 0 :(得分:2)
生成空白视频时没有音频流。解决方案是在视频中添加静音音频流:
ffmpeg -y -f lavfi -i anullsrc -i 2-seconds-silent-video.mp4 -shortest -c:v copy -c:a aac -strict experimental silent-video.mp4
在这里由@miindlek回答,谢谢。
我在上面找到了这一行:adding silent audio in ffmpeg