Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Splitting m4a into multiple files with ffmpeg

Tags:

unix

ffmpeg

audio

I have an audio file (.m4a) and want to split it into smaller pieces using ffmpeg. All answers I have seen do something along one of the following two possibilities:

  1. ffmpeg -i inputFile -map 0 -f segment -segment_time 60 -c copy "$output%03d.m4a

or

  1. ffmpeg -i inputFile -acodec copy -ss start_time -to end_time outputFile

With 1. the first file is fine. From the second file on, I just get a minute of silence in quicktime, and in VLC the file plays but the timing is odd: for example the second file should have second 0 equals to second 60 in the original file. However in vlc it starts playing on second 60 and goes on to second 120.

With 2. I have to set start times and end for each file, unfortunately I notice a small jump when I play one after the other, so it seems as if some miliseconds are lost.

There are definitely a few old questions asked around this, but none of them actually helped me with this.

like image 652
ARuiz Avatar asked Oct 27 '25 01:10

ARuiz


1 Answers

Quicktime probably doesn't like files starting with a timestamp other than 0.

Use

ffmpeg -i inputFile -map 0 -f segment -segment_time 60 -reset_timestamps 1 -c copy "$output%03d.m4a
like image 84
Gyan Avatar answered Oct 29 '25 17:10

Gyan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!