我试图连接3个mp4视频,每个视频都使用ffmpeg包含3个音频流,因为由于编解码器私有数据的差异,我无法将它们与其他软件合并。
由于文件具有不同的编解码器,因此我尝试使用concat视频过滤器,但似乎无法正常工作。输出结果是无法播放的文件。我试图指定输入文件和每个媒体流,然后告诉软件将其连接起来并复制到输出文件中。
//HTML
<div class="stripebar"></div>
//CSS
.stripebar{
height: 5px; //or whatever height you want your div to be
border-top: 5px solid;
border-image: linear-gradient(-45deg, red 32%, white 32.5%, white 33%,
white 33.5%, blue 34%) 5;
}
完整的日志:
ffmpeg -i A.mp4 -i B.mp4 -i C.mp4 -filter_complex '[0:0] [0:1] [0:2] [0:3] [1:0] [1:1] [1:2] [1:3] [2:0] [2:1] [2:2] [2:3] concat=n=3:v=1:a=3 [v] [a1] [a2] [a3]' -map '[v]' -map '[a1]' -map '[a2]'-map '[a3]' output.mp4
这是尝试concat多路分配器时的输出,它还会生成无法播放的文件。
ffmpeg -i A.mp4 -i B.mp4 -i C.mp4 -filter_complex '[0:0] [0:1] [0:2] [0:3] [1:0] [1:1] [1:2] [1:3] [2:0] [2:1] [2:2] [2:3] concat=n=3:v=1:a=3 [v] [a1] [a2] [a3]' -map '[v]' -map '[a1]' -map '[a2]'-map '[a3]' output.mp4
ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20190212
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'A.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : HandBrake 0.10.1 2015030800
Duration: 01:59:10.12, start: 0.000000, bitrate: 6868 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 6017 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 320 kb/s (default)
Metadata:
handler_name : Stereo
Stream #0:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 320 kb/s
Metadata:
handler_name : Surround
Stream #0:3(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
handler_name : Stereo
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'B.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : HandBrake 0.10.1 2015030800
Duration: 01:12:28.48, start: 0.000000, bitrate: 6846 kb/s
Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 6001 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 320 kb/s (default)
Metadata:
handler_name : Stereo
Stream #1:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 320 kb/s
Metadata:
handler_name : Surround
Stream #1:3(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
handler_name : Stereo
Input #2, mov,mp4,m4a,3gp,3g2,mj2, from 'C.mp4':
Metadata:
major_brand : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : HandBrake 0.10.1 2015030800
Duration: 00:58:55.53, start: 0.000000, bitrate: 6850 kb/s
Stream #2:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 6005 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandler
Stream #2:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 319 kb/s (default)
Metadata:
handler_name : Stereo
Stream #2:2(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 319 kb/s
Metadata:
handler_name : Surround
Stream #2:3(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 192 kb/s
Metadata:
handler_name : Stereo
Stream mapping:
Stream #0:0 (h264) -> concat:in0:v0
Stream #0:1 (aac) -> concat:in0:a0
Stream #0:2 (aac) -> concat:in0:a1
Stream #0:3 (aac) -> concat:in0:a2
Stream #1:0 (h264) -> concat:in1:v0
Stream #1:1 (aac) -> concat:in1:a0
Stream #1:2 (aac) -> concat:in1:a1
Stream #1:3 (aac) -> concat:in1:a2
Stream #2:0 (h264) -> concat:in2:v0
Stream #2:1 (aac) -> concat:in2:a0
Stream #2:2 (aac) -> concat:in2:a1
Stream #2:3 (aac) -> concat:in2:a2
concat:out:v0 -> Stream #0:0 (libx264)
concat:out:a0 -> Stream #0:1 (aac)
concat:out:a1 -> Stream #0:2 (aac)
concat:out:a2 -> Stream #0:3 (aac)
Press [q] to stop, [?] for help
[libx264 @ 000001930c898980] using SAR=1/1
[libx264 @ 000001930c898980] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 000001930c898980] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 000001930c898980] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - 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=12 lookahead_threads=2 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 : mp42
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default)
Metadata:
encoder : Lavc58.35.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.35.100 aac
Stream #0:2: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 341 kb/s
Metadata:
encoder : Lavc58.35.100 aac
Stream #0:3: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.35.100 aac
[aac @ 000001930d3a88c0] skip_data_stream_element: Input buffer exhausted before END element found
Error while decoding stream #0:1: Invalid data found when processing input
[aac @ 000001930c89a4c0] Number of bands (48) exceeds limit (47).ate=6048.4kbits/s dup=1 drop=0 speed=0.916x
Error while decoding stream #2:1: Invalid data found when processing input
frame=450571 fps= 28 q=-1.0 Lsize=11204203kB time=04:10:34.13 bitrate=6105.1kbits/s dup=1 drop=0 speed=0.939x
video:10071486kB audio:1099256kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.299544%
[libx264 @ 000001930c898980] frame I:4679 Avg QP:20.30 size:103274
[libx264 @ 000001930c898980] frame P:125629 Avg QP:22.82 size: 41052
[libx264 @ 000001930c898980] frame B:320263 Avg QP:25.08 size: 14590
[libx264 @ 000001930c898980] consecutive B-frames: 2.3% 6.0% 8.8% 83.0%
[libx264 @ 000001930c898980] mb I I16..4: 16.4% 78.4% 5.2%
[libx264 @ 000001930c898980] mb P I16..4: 7.0% 17.1% 1.1% P16..4: 43.0% 9.7% 4.9% 0.0% 0.0% skip:17.3%
[libx264 @ 000001930c898980] mb B I16..4: 0.8% 1.7% 0.1% B16..8: 39.4% 3.6% 0.7% direct: 4.3% skip:49.4% L0:43.8% L1:50.2% BI: 6.0%
[libx264 @ 000001930c898980] 8x8 transform intra:68.6% inter:84.9%
[libx264 @ 000001930c898980] coded y,uvDC,uvAC intra: 40.3% 64.9% 17.2% inter: 12.9% 24.2% 0.4%
[libx264 @ 000001930c898980] i16 v,h,dc,p: 40% 22% 10% 28%
[libx264 @ 000001930c898980] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 15% 23% 5% 6% 7% 5% 6% 5%
[libx264 @ 000001930c898980] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 16% 16% 6% 9% 9% 7% 6% 5%
[libx264 @ 000001930c898980] i8c dc,h,v,p: 48% 20% 26% 6%
[libx264 @ 000001930c898980] Weighted P-Frames: Y:8.6% UV:6.4%
[libx264 @ 000001930c898980] ref P L0: 58.8% 12.5% 19.8% 8.4% 0.4%
[libx264 @ 000001930c898980] ref B L0: 88.5% 9.1% 2.4%
[libx264 @ 000001930c898980] ref B L1: 96.9% 3.1%
[libx264 @ 000001930c898980] kb/s:5487.92
[aac @ 000001930c899280] Qavg: 212.043
[aac @ 000001930d1cfbc0] Qavg: 211.329
[aac @ 000001930d1ce080] Qavg: 228.685
答案 0 :(得分:1)
尝试一下:
s =给定视频文件的分辨率
//command
ffmpeg -y -i INPUT.mp4 -i INPUT.mp4 -filter_complex [0:v]scale=1080x640,setsar=1:1[v0];[1:v]scale=1080x640,setsar=1:1[v1];[v0][0:a][v1][1:a] concat=n=2:v=1:a=1 -ab 48000 -ac 2 -ar 22050 -s 1080x640 -vcodec libx264 -crf 10 -q 4 -preset ultrafast OUTPUT.mp4