Concatenating audio files results in a file of the wrong length

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Concatenating audio files results in a file of the wrong length

Stephanye Carrier
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.

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Concatenating audio files results in a file of the wrong length

Carl Eugen Hoyos-2
Am Fr., 19. Juni 2020 um 21:25 Uhr schrieb Stephanye Carrier
<[hidden email]>:
>
> 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.

This is often not possible because of how audio and video are
interleaved in files.

> 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

Please remove -hide_banner if you want to support on this mailing list
and provide the command lines you tested together with the complete,
uncut console output.

Filters exist that allow you to cut and re-encode in one operation, this
will avoid the resync.
And if above input file is not the original, use originals instead.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".