OSX: Save Quicktime audio stream to a file using VLC
I found a Mac OS X hint yesterday mentioning how VideoLAN CLient (VLC) can save streaming videos into a file. Since today I wanted to record a radio show off the Internet, I gave it a shot for an audio stream too.
Here’s what I got:
If you want to save a Quicktime (AAC/MP4) audio stream (maybe others, too? Leave a comment if you know!) to a file, start VLC from the command line (terminal window) like this:
/Applications/VLC.app/Contents/MacOS/VLC –rtsp-tcp \
rtsp://example.com/path/to/stream \
–sout ‘#standard{access=file,mux=mp4,url=/Users/\
Shared/VLCoutput.mp4}’
(obviously, you needn’t break it up into several lines of code, you can just leave out the line breaks as well as the backslashes: We will use that format in a jiffy).
Now, if you want to schedule the whole thing, a cron job will do the job. The tool at would be certainly more correct (since you don’t want to schedule it as a recurrent task), but the at daemon is disabled on OS X by default.
So, do a crontab -e and put in two lines like this (yes, put the whole VLC stuff into one line as mentioned above):
0 15 12 5 * /Applications/VLC.app/Contents/MacOS/VLC --rtsp-tcp rtsp://example.com/path/to/stream --sout '#standard{access=file,mux=mp4,url=/Users/Shared/VLCoutput.mp4}'
30 15 12 5 * killall -QUIT VLC
The first line starts VLC as mentioned above. 0 15 12 5 means: Start at 3 p.m. (= 0 15), on May 12 (= 12 5). The asterisks in each of the lines just mean that you don’t care about the weekday.
The second command, accordingly, stops recording at 3:30 p.m. by killing the VLC process. Two notes on that:
First, keep in mind to sind the QUIT signal rather than TERM (which would be the default), otherwise VLC won’t correctly finish writing the file and probably render it unusable.
Second, killall is the mass murderer of the kill() commands. It will kill all running instances of VLC, not just the one recording your stream. So, don’t wonder if the movie you happen to be watching stops playing at the scheduled time.
Save it and you are all set: Your stream will be recorded at the right time. You will find your stream in the Users/Shared/ folder, as specified in the VLC command line.
Eventually, when everything is done, you do a crontab -e again, and remove the two lines so that it won’t start recording again, a year from now
Have fun listening!
September 1st, 2007 at 1:42 am
Thanks very much for this post, the code was invaluable and works perfectly – I made some adjustments to record a .asf file, but without the code above I’d have got nowhere. Thanks a million!
September 1st, 2007 at 2:13 am
You’re very welcome