Search code examples
audioffmpegconcatenationaacdolby

Concatenate audio files using ffmpeg


I am trying to concatenate ac3 and aac using ffmpeg.

ffprobe of jpn_op.m4a:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'jpn_op.m4a':
Metadata:
major_brand     : M4A 
minor_version   : 512
compatible_brands: M4A isomiso2
encoder         : Lavf58.76.100
Duration: 00:01:17.28, start: 0.000000, bitrate: 224 kb/s
Stream #0:0(jpn): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 224 kb/s (default)
Metadata:
  handler_name    : SoundHandler
  vendor_id       : [0][0][0][0]
Side data:
  audio service type: main

ffprobe of eng_nop.m4a

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'eng_nop.m4a':
Metadata:
major_brand     : M4A 
minor_version   : 512
compatible_brands: M4A isomiso2
encoder         : Lavf58.76.100
Duration: 00:22:09.26, start: 0.023000, bitrate: 41 kb/s
Stream #0:0(und): Audio: aac (HE-AAC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 39 kb/s (default)
Metadata:
  handler_name    : SoundHandler
  vendor_id       : [0][0][0][0]

I tried this:

ffmpeg -f concat -i concat_files.txt -c copy final.m4a -y

concat_files.txt contains:

file 'jpn_op.m4a'
file 'eng_nop.m4a'

ffprobe of final.m4a

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'final.m4a':
Metadata:
major_brand     : M4A 
minor_version   : 512
compatible_brands: M4A isomiso2
encoder         : Lavf58.76.100
Duration: 00:23:26.50, start: 0.000000, bitrate: 51 kb/s
Stream #0:0(jpn): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, stereo, fltp, 224 kb/s (default)
Metadata:
  handler_name    : SoundHandler
  vendor_id       : [0][0][0][0]
Side data:
  audio service type: main

But, there is silent in place of 2nd file in final.m4a


Solution

  • Formats and attributes must be the same for concat demuxer to work. Re-encode one of the files to match the other then concatenate.

    Or use the concat filter instead:

    ffmpeg -i jpn_op.m4a -i eng_nop.m4a -filter_complex "[0:a][1:a]concat=n=2:v=0:a=1" final.mp4