我想使用concat
过滤器连接两个视频文件。必须完全包含第一个文件,而第二个视频必须包含在第10个秒中。我是否需要首先从第10秒开始创建一个中间文件,或者我可以一步完成吗?
我使用的命令是
/usr/local/bin/ffmpeg -i intro.mp4 -i input.mp4 -filter_complex '[0:v] scale=720:576 [in1]; [1:v] scale=720:576 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]' output.mp4
我尝试在-ss
之后指定-i input.mp4
,但它会应用于最终输出文件。
iMac:files joyce$ /usr/local/bin/ffmpeg -i intro.mp4 -i input.mp4 -filter_complex '[0:v] scale=720:576 [in1]; [1:v] scale=720:576 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]' output.mp4
ffmpeg version 2.1.4 Copyright (c) 2000-2014 the FFmpeg developers
built on Mar 22 2014 16:19:43 with Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.1.4 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libfdk-aac
libavutil 52. 48.101 / 52. 48.101
libavcodec 55. 39.101 / 55. 39.101
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libavresample 1. 1. 0 / 1. 1. 0
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'intro.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Duration: 00:00:03.05, start: 0.046440, bitrate: 1304 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1920x1080, 1167 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 132 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
episode_sort : 1
season_number : 1
media_type : 9
hd_video : 0
Duration: 00:00:45.43, start: 0.042667, bitrate: 906 kb/s
Stream #1:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 720x576 [SAR 1:1 DAR 5:4], 774 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
Metadata:
handler_name : SoundHandler
File 'output.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x7fa9a8828e00] using SAR=1/1
[libx264 @ 0x7fa9a8828e00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x7fa9a8828e00] profile High, level 3.1
[libx264 @ 0x7fa9a8828e00] 264 - core 125 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf55.19.104
Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x576 [SAR 1:1 DAR 5:4], q=-1--1, 30k tbn, 29.97 tbc (default)
Stream #0:1: Audio: aac (libfaac) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
Stream mapping:
Stream #0:0 (h264) -> scale
Stream #0:1 (aac) -> concat:in0:a0
Stream #1:0 (h264) -> scale
Stream #1:1 (aac) -> concat:in1:a0
concat -> Stream #0:0 (libx264)
concat -> Stream #0:1 (libfaac)
Press [q] to stop, [?] for help
frame= 1453 fps= 42 q=-1.0 Lsize= 4536kB time=00:00:48.50 bitrate= 766.1kbits/s dup=227 drop=0
video:3796kB audio:691kB subtitle:0 global headers:0kB muxing overhead 1.102067%
[libx264 @ 0x7fa9a8828e00] frame I:31 Avg QP:17.02 size: 14953
[libx264 @ 0x7fa9a8828e00] frame P:764 Avg QP:24.14 size: 3677
[libx264 @ 0x7fa9a8828e00] frame B:658 Avg QP:28.17 size: 933
[libx264 @ 0x7fa9a8828e00] consecutive B-frames: 36.4% 6.2% 10.3% 47.1%
[libx264 @ 0x7fa9a8828e00] mb I I16..4: 40.4% 32.3% 27.3%
[libx264 @ 0x7fa9a8828e00] mb P I16..4: 6.6% 4.0% 1.1% P16..4: 25.2% 5.7% 2.3% 0.0% 0.0% skip:55.0%
[libx264 @ 0x7fa9a8828e00] mb B I16..4: 0.8% 0.4% 0.2% B16..8: 24.5% 1.7% 0.2% direct: 0.5% skip:71.6% L0:50.7% L1:45.5% BI: 3.9%
[libx264 @ 0x7fa9a8828e00] 8x8 transform intra:33.3% inter:59.0%
[libx264 @ 0x7fa9a8828e00] coded y,uvDC,uvAC intra: 26.4% 41.2% 8.0% inter: 5.6% 7.9% 0.2%
[libx264 @ 0x7fa9a8828e00] i16 v,h,dc,p: 46% 29% 8% 17%
[libx264 @ 0x7fa9a8828e00] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 19% 28% 3% 3% 4% 3% 4% 3%
[libx264 @ 0x7fa9a8828e00] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 22% 13% 4% 6% 7% 5% 5% 3%
[libx264 @ 0x7fa9a8828e00] i8c dc,h,v,p: 57% 19% 20% 4%
[libx264 @ 0x7fa9a8828e00] Weighted P-Frames: Y:1.8% UV:1.2%
[libx264 @ 0x7fa9a8828e00] ref P L0: 73.2% 9.1% 11.7% 5.3% 0.7%
[libx264 @ 0x7fa9a8828e00] ref B L0: 89.3% 8.9% 1.8%
[libx264 @ 0x7fa9a8828e00] ref B L1: 95.3% 4.7%
[libx264 @ 0x7fa9a8828e00] kb/s:641.26
答案 0 :(得分:1)
我在-ss
选项之后放置了-i
参数,这就是为什么没有正确应用它。
/usr/local/bin/ffmpeg -i intro.mp4 -i input.mp4 -ss 1.5 -filter_complex '[0:v] scale=720:576 [in1]; [1:v] scale=720:576 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]' output.mp4
我尝试将它放在-i
选项之前,现在它按预期工作。
/usr/local/bin/ffmpeg -i intro.mp4 -ss 1.5 -i input.mp4 -filter_complex '[0:v] scale=720:576 [in1]; [1:v] scale=720:576 [in2]; [in1][in2] concat [v]; [0:a][1:a] concat=v=0:a=1 [a]' -map '[v]' -map '[a]' output.mp4