[FFmpeg-user] FFMPEG - Concatenate 2 MP4 Files, one has video and audio and the other has only audio

Avinash Jairam avinashjairam at gmail.com
Sat Jul 16 23:12:06 CEST 2016


Dear All,

I hope you can help me with this issue.

I am trying to merge 2 mp4 files using FFMPEG. One of these files has both
video and audio (track1.mp4), while the other one has only audio (track2.mp4).
The names of these files are listed in a text file called 'filesToMerge.txt' in
the following manner:

file 'track1.mp4'
file 'track2.mp4'

I then execute the following ffmpeg command to merge them.

ffmpeg -f concat -i filesToMerge.txt -c copy output.mp4

However, the concatenated file that is generated consists of only the first
file that is listed in filesToMerge.txt. That is, if track1.mp4 (which has
both video and audio) is the first file in the list, then only that file
makes up output.mp4 (the concatenated file produced) and vice versa.

I would like for both files to be in output.mp4. I am using Ubuntu 14.04
(if that helps). How can I solve this problem?

When I run this command ffmpeg -i track1.mp4 -i track2.mp4 output.mp4 I get
the following:

ffmpeg version N-76944-g15206ff Copyright (c) 2000-2015 the FFmpeg developers
      built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04)
      configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg
--enable-avresample --disable-debug --enable-nonfree --enable-gpl
--enable-version3 --enable-libopencore-amrnb
--enable-libopencore-amrwb --disable-decoder=amrnb
--disable-decoder=amrwb --enable-libpulse --enable-libdcadec
--enable-libfreetype --enable-libx264 --enable-libx265
--enable-libfdk-aac --enable-libvorbis --enable-libmp3lame
--enable-libopus --enable-libvpx --enable-libspeex --enable-libass
--enable-avisynth --enable-libsoxr --enable-libxvid
--enable-libvo-aacenc --enable-libvidstab
      libavutil      55.  9.100 / 55.  9.100
      libavcodec     57. 16.101 / 57. 16.101
      libavformat    57. 19.100 / 57. 19.100
      libavdevice    57.  0.100 / 57.  0.100
      libavfilter     6. 17.100 /  6. 17.100
      libavresample   3.  0.  0 /  3.  0.  0
      libswscale      4.  0.100 /  4.  0.100
      libswresample   2.  0.101 /  2.  0.101
      libpostproc    54.  0.100 / 54.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'track1.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2avc1mp41
        encoder         : Lavf56.40.101
      Duration: 00:00:10.76, start: 0.023220, bitrate: 351 kb/s
        Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661),
yuv420p, 800x400 [SAR 400:533 DAR 800:533], 181 kb/s, 25 fps, 25 tbr,
12800 tbn, 50 tbc (default)
        Metadata:
          handler_name    : VideoHandler
        Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100
Hz, stereo, fltp, 194 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
    Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'track2.mp4':
      Metadata:
        major_brand     : isom
        minor_version   : 512
        compatible_brands: isomiso2mp41
        creation_time   : 1970-01-01 00:00:00
        encoder         : Lavf52.32.0
      Duration: 00:00:32.21, start: 0.000000, bitrate: 46 kb/s
        Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000
Hz, stereo, fltp, 43 kb/s (default)
        Metadata:
          creation_time   : 1970-01-01 00:00:00
          handler_name    : SoundHandler
    [libx264 @ 0x3950ce0] using SAR=400/533
    [libx264 @ 0x3950ce0] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
    [libx264 @ 0x3950ce0] profile High, level 3.0
    [libx264 @ 0x3950ce0] 264 - core 142 r2491 24e4fed - H.264/MPEG-4
AVC codec - Copyleft 2003-2014 - 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=1 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         : Lavf57.19.100
        Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] /
0x0021), yuv420p, 800x400 [SAR 400:533 DAR 800:533], q=-1--1, 25 fps,
12800 tbn, 25 tbc (default)
        Metadata:
          handler_name    : VideoHandler
          encoder         : Lavc57.16.101 libx264
        Stream #0:1(und): Audio: aac (libfdk_aac) ([64][0][0][0] /
0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
        Metadata:
          handler_name    : SoundHandler
          encoder         : Lavc57.16.101 libfdk_aac
    Stream mapping:
      Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
      Stream #0:1 -> #0:1 (aac (native) -> aac (libfdk_aac))
    Press [q] to stop, [?] for help
    frame=  270 fps= 99 q=28.0 Lsize=     382kB time=00:00:10.72
bitrate= 291.9kbits/s dup=1 drop=0
    video:230kB audio:143kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 2.482656%
    [libx264 @ 0x3950ce0] frame I:2     Avg QP:18.87  size:109452
    [libx264 @ 0x3950ce0] frame P:68    Avg QP:15.09  size:   171
    [libx264 @ 0x3950ce0] frame B:200   Avg QP:23.33  size:    23
    [libx264 @ 0x3950ce0] consecutive B-frames:  1.1%  0.0%  1.1% 97.8%
    [libx264 @ 0x3950ce0] mb I  I16..4: 11.0% 39.6% 49.5%
    [libx264 @ 0x3950ce0] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:
5.9%  0.1%  0.0%  0.0%  0.0%    skip:93.9%
    [libx264 @ 0x3950ce0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:
0.3%  0.0%  0.0%  direct: 0.0%  skip:99.7%  L0:21.8% L1:78.2% BI: 0.0%
    [libx264 @ 0x3950ce0] 8x8 transform intra:39.7% inter:92.8%
    [libx264 @ 0x3950ce0] coded y,uvDC,uvAC intra: 92.0% 95.0% 73.2%
inter: 0.1% 1.4% 0.0%
    [libx264 @ 0x3950ce0] i16 v,h,dc,p:  1% 30%  4% 66%
    [libx264 @ 0x3950ce0] i8 v,h,


Sincerely,


Avinash Jairam


More information about the ffmpeg-user mailing list