为什么 ffmpeg 与 2 个视频连接会丢失第二个音频


Why ffmpeg concat with 2 videos is losing the 2nd audio?

我正在尝试合并视频(具有各自的音频),但是当尝试连接 2 个不同的视频源时,第二个音频无法播放。

(视频.txt有 2 个视频我试图连接)

shell_exec('ffmpeg -f concat -i videos.txt -crf 30 -c:a aac -strict experimental output.mp4');

任何帮助将不胜感激!

谢谢!!

两个文件的FFPROBE:

ffprobe version N-76417-gee20354 Copyright (c) 2007-2015 the FFmpeg developers built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --prefix=/home/dmarcos89/ffmpeg_build --extra-cflags=-I/home/dmarcos89/ffmpeg_build/include --extra-ldflags=-L/home/dmarcos89/ffmpeg_build/lib --bindir=/usr/local/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 5.100 / 55. 5.100 libavcodec 57. 13.102 / 57. 13.102 libavformat 57. 13.100 / 57. 13.100 libavdevice 57. 0.100 / 57. 0.100 libavfilter 6. 14.101 / 6. 14.101 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.100 / 2. 0.100 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 't1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.13.100 Duration: 00:00:10.14, start: 0.042667, bitrate: 1343 kb/s Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1183 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, 5.1, fltp, 161 kb/s (default) Metadata: handler_name : SoundHandler ffprobe version N-76417-gee20354 Copyright (c) 2007-2015 the FFmpeg developers built with gcc 4.6 (Ubuntu/Linaro 4.6.3-1ubuntu5) configuration: --prefix=/home/dmarcos89/ffmpeg_build --extra-cflags=-I/home/dmarcos89/ffmpeg_build/include --extra-ldflags=-L/home/dmarcos89/ffmpeg_build/lib --bindir=/usr/local/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 libavutil 55. 5.100 / 55. 5.100 libavcodec 57. 13.102 / 57. 13.102 libavformat 57. 13.100 / 57. 13.100 libavdevice 57. 0.100 / 57. 0.100 libavfilter 6. 14.101 / 6. 14.101 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.100 / 2. 0.100 libpostproc 54. 0.100 / 54. 0.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 't2.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.13.100 Duration: 00:00:07.32, start: 0.042667, bitrate: 3616 kb/s Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 3487 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default) Metadata: handler_name : SoundHandler

这是尝试连接后输出消息的开始(整个输出非常大,并重复"解码流时出错 #0:1:无效数据...":

'

Input #0, concat, from 'videos.txt':
  Duration: N/A, start: 0.000000, bitrate: 1129 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 639 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 490 kb/s
    Metadata:
      handler_name    : SoundHandler
[libx264 @ 0x2dd3540] using SAR=1/1
[libx264 @ 0x2dd3540] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX XOP FMA4 SSEMisalign LZCNT
[libx264 @ 0x2dd3540] profile High, level 3.1
[libx264 @ 0x2dd3540] 264 - core 120 r2151 a3f4407 - H.264/MPEG-4 AVC codec - Copyleft 2003-2011 - 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=24 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=30.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:
    encoder         : Lavf57.13.100
    Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc57.13.102 libx264
    Stream #0:1(und): Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, 5.1, fltp, 128 kb/s
    Metadata:
      handler_name    : SoundHandler
      encoder         : Lavc57.13.102 aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
frame=   43 fps=0.0 q=0.0 size=       0kB time=00:00:02.28 bitrate=   0.2kbits/s dup=1 drop=0    
frame=   80 fps= 80 q=35.0 size=      44kB time=00:00:03.75 bitrate=  96.0kbits/s dup=1 drop=0    
[mov,mp4,m4a,3gp,3g2,mj2 @ 0xa559a80] Auto-inserting h264_mp4toannexb bitstream filter
[aac @ 0x2daa540] channel element 1.0 is not allocated
Error while decoding stream #0:1: Invalid data found when processing input

'

将第二个视频转换为具有5.1音频流的视频,然后使用新文件运行连接。

ffmpeg -i t2.mp4 -c:v copy -c:a aac -strict -2 -ac 6 t2-6ch.mp4