[FFmpeg-user] Concatenating audio files results in a file of the wrong length

Stephanye Carrier stoozor at gmail.com
Fri Jun 19 22:16:22 EEST 2020


I have a project that requires me to demux audio from video files, cut 
the audio up in parts, then concatenate the parts back together and 
remux the audio and video together.
However, I am running into an issue where the resulting audio file is 
the wrong length which results in a desync.

ffmpeg -hide_banner -i video.mp4 -vn -acodec copy audio.m4a
ffmpeg -hide_banner -ss xx:xx:xx -i audio.m4a -to xx:xx:xx -c copy PartX.m4a
ffmpeg -hide_banner -f concat -safe 0 -i concat.txt -c copy newaudio.m4a

FFprobe of the original file :
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'audio.m4a':
   Metadata:
     major_brand     : M4A
     minor_version   : 512
     compatible_brands: M4A isomiso2
     encoder         : Lavf58.39.101
   Duration: 04:29:16.43, start: 0.003000, bitrate: 164 kb/s
     Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, fltp, 160 kb/s (default)
     Metadata:
       handler_name    : SoundHandler

FFprobe of the concatenated file :
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'newaudio.m4a':
   Metadata:
     major_brand     : M4A
     minor_version   : 512
     compatible_brands: M4A isomiso2
     encoder         : Lavf58.39.101
   Duration: 04:32:04.47, start: 0.000000, bitrate: 164 kb/s
     Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, fltp, 160 kb/s (default)
     Metadata:
       handler_name    : SoundHandler

FFProbe of one of the audio parts :
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Part0.m4a':
   Metadata:
     major_brand     : M4A
     minor_version   : 512
     compatible_brands: M4A isomiso2
     encoder         : Lavf58.39.101
   Duration: 00:02:48.02, start: 0.000000, bitrate: 165 kb/s
     Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, fltp, 160 kb/s (default)
     Metadata:
       handler_name    : SoundHandler

I do not know if it's relevant, but the original video file is made of 
.ts chunks concatenated together then remuxed to an mp4.
How can I fix the length issue? Thank you.



More information about the ffmpeg-user mailing list