Saturday, September 20, 2014
Extracting the mp3 From a Video
(In reference to a recent SFVLUG meeting....)
At the last meeting the question of how to extract an audio already in mp3 format from a video into a stand alone file came up.
I suggested something along the lines of
$ ffmpeg -i videofile -ac copy audiofile.mp3
making sure the output file has an extension of '.mp3', which is almost right but has an error.
It should be:
$ ffmpeg -i videofile -acodec copy audiofile.mp3
I mentioned mkvextract if the file was already matroska in the conversation. This actually implies another method of doing this, first convert to matroska with mkvmerge, then use mkvextract to dump the audio track:
$ mkvmerge -o intermediate_video.mkv videofile
$ mkvextract tracks intermediate_video.mkv 1:audiofile.mp3
$ rm -f intermediate_video.mkv
assuming, as typically happens, that track 1 of the matroska is the audio file. That probably should be verified, with
$ mkvmerge --identify intermediate_video.mkv
Yet another approach would be
$ mplayer -dumpaudio -dumpfile audiofile.mp3 videofile
Apparently mpv, an mplayer fork, does not currently support '--dumpaudio'. (To my suprise.)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment