How to rip the audio from a video?
I am on ubuntu and want to convert a mp4 video to an mp3 audio file but can't figure out how. I tried installing ffmpeg but it failed to encode the mp3. I've read the gstreamer does it but I can't figure out how. I have gstreamer and python installed. I can program with python, but a开发者_如何学Gom not super comfortable compiling software from source or any higher level command line stuff. I only know the basics on the command line.
mplayer <videofile> -dumpaudio -dumpfile out.bin
it will copy the raw audio stream, that should then be easily converted using sox, lame, vlc or whatnot. VLC has nice conversion options as well - and it sports a GUI. I don't know about extracting just the audio, but it should sure be capable of it
Use TAE https://github.com/tuna74/TunaAudioExtracter. It does everything you want.
Easiest way to do this using GStreamer is to create GStreamer pipeline with decodebin element using gst-launch
command-line utility:
gst-launch-1.0 filesrc location=in.mp4 ! decodebin ! audioconvert ! lamemp3enc ! filesink location=out.mp3
In case your mp4 file contains audio track in mp3 format you may want to avoid re-encoding:
gst-launch-1.0 filesrc location=in.mp4 ! qtdemux ! audio/mpeg ! filesink location=out.mp3
If you want to use FFMPEG, you can use following command:
ffmpeg -i in.mp4 out.mp3
You can avoid re-encoding (in case audio track is in mp3) with -acodec copy
option:
ffmpeg -i in.mp4 -acodec copy out.mp3
hmm, for an easy python solution, you could always checkout the python video converter, on https://pypi.python.org/pypi/video-converter a sample code is as follows:
from converter import Converter
c = Converter()
conv = c.convert('g.mp4', 'clip5.mp3', {'format':'mp3','audio':{'codec': 'mp3','bitrate':'22050','channels':1}})
for timecode in conv:
pass
where clip5.mp3 is the name of the output file,
精彩评论