Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have several long audio files (80 minutes each; m4a) and want them split into 5- or 10-minute pieces.

I see many questions for splitting an audio file at extended pauses, tones, etc. but can't seem to find one regarding this simple operation. Does anyone know a simple way to do this?

Of course, something automatic, and command-line is okay—even preferred.

Thanks in advance!

share|improve this question

4 Answers 4

up vote 7 down vote accepted

Here's a one-liner, you just need Ruby and FFmpeg installed:

ruby -e '(0..4500).step(300) { |x| system "ffmpeg -ss #{x} -i in.m4a -c copy -t 300 out-#{x}.m4a"}'

Simply execute that in the same folder where in.m4a is. It'll copy the audio bitstream, so executing this will probably take less than a few seconds.

To explain:

  • 4800 seconds is the length of the audio file (80 minutes × 60 seconds), so our last split is at 4500 (4800 - 300 seconds).
  • We go from 0 to 4500, and we split every 300 seconds (5min × 60s).
  • FFmpeg will start at the time specified by -ss
  • And it'll copy for the time specified by -t
  • It'll write several output files called out-<x>.mp4, where <x> is the start time in seconds.
share|improve this answer
    
Thanks! Is your command for UNIX, or does it work on Windows too? I have a Cygwin installation, so it shouldn't matter, but just wondering. I'll try it when I get home. –  Andrew Cheong Dec 28 '12 at 14:54
    
This natively works on Linux (and Unixes that have Ruby installed), and it should also work on Windows – you simply need Ruby and FFmpeg, but you won't need Cygwin for that. There's Ruby Installer and FFmpeg executables for Windows as well. Now, the FFmpeg command could be automated without Ruby, using Windows batch files, or PowerShell, but I'm not a Windows user, so that's why I took Ruby (because it comes with Linux and OS X). Maybe someone with Windows batch experience can rewrite the Ruby command above? –  slhck Dec 28 '12 at 15:03
    
I have Cygwin because I can't get used to the Windows command-line. I think I already have ruby and ffmpeg installed there, so I should be able to use your command. But yes, a Windows version might help someone else viewing this question. +1 for now; will accept when I try it. –  Andrew Cheong Dec 28 '12 at 15:35
1  
If, like me, your m4a file includes a video stream (in my case, a single image) then you need to add the -vn switch to select just the audio stream. If you want to keep the video stream you'll need to output to a file with an .mp4 extension. –  Rob Church Feb 1 '14 at 20:52

I was looking for a solution for this myself. The easiest way I found to do this is via MP4Box:

mp4box -split 300 infile.m4a

Where "300" is the time in seconds. MP4Box will automatically write numbered output files.

(You don't need to install the whole big GPAC application. These are the files you can extract from the archive for it to work: js.dll; libeay32.dll; libgpac.dll; MP4Box.exe; ssleay32.dll)

share|improve this answer

It has been a while since this question was asked, but after fooling around with Ruby and ffmpeg I decided there has to be an easier way to do this within Windows, and I found there is.

Download and install Audacity

Create a text file somewhere you can find it and paste the following string into it: (300 second intervals, ie. 5 minutes, 10 minutes would be 600 intervals, etc...)

0       300  
300     600  
600     900  
900     1200  
1200    1500  
1500    1800  
1800    2100  
2100    2400  
2400    2700  
2700    3000  
3000    3300  
3300    3600  
3600    3900  
3900    4200  
4200    4500  
4500    4800  
4800    5100  
5100    5400  
5400    5700  
5700    6000  
6000    6300  
6300    6600  
6600    7200  
6900    7200  
7200    7500  
7500    7800  
7800    8100  
8100    8400  
8400    8700  
8700    9000  
9000    9300  
9300    9600  
9600    9900  
9900    10200  
10200   10500  
10500   10800  
10800   11100  
11100   11400  
11400   11700  
11700   12000  
12000   12300  
12300   12600  
12600   12900  
12900   13200  
13200   13500  
13500   13800  
13800   14100  
14100   14400  
14400   14700  
14700   15000  

Just make sure that the numbers of intervals is greater than the total length of your audio files, I created this one which runs for over three hours, plenty long for my needs, append more to it to suit your needs.

Import the audio file into Audacity and make whatever balancing and whatever other edits you want to, then click on file>labels>import labels

select your text file, then select the label track and the audio track at the same time and click on file>export multiple

change the filetype you want to export to and adjust the settings, then select the destination folder.

I always change the numbering pattern to Numbering After Filename Prefix and type the filename I want in the box and the program will add the numbers, hit Export and viola!

share|improve this answer

Download Audacity - It's a free audio tool that can do exactly what you need, and it's totally free and easy to use. http://audacity.sourceforge.net/

share|improve this answer
1  
Is there a way to make Audacity do this automatically? I wouldn't want to manually chop multiple files into 16 pieces each by selecting 5-minute pieces with my mouse, cut them, go to the menu, save the files, et cetera. –  slhck Dec 28 '12 at 14:41
    
I already have Audacity, so if there is an automatic way, please let me know! –  Andrew Cheong Dec 28 '12 at 14:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.