Multimedia/MencoderAudioOnly
Whatever you can play with mplayer, whether it be an avi, mkv, mp4, ogm, etc it can be made into an MP3 or whatever other format is necessary easily.
Method 1: Dumping the audio
Sometimes you get lucky and your encoded file has the audio encoded by MP3. Then you can just have mplayer dump the audio.
You can check and see if the video's audio encoding using file.
# file Ranma\ One-Half/Season\ 01/01.\ Here\'s\ Ranma.avi Ranma One-Half/Season 01/01. Here's Ranma.avi: RIFF (little-endian) data, AVI, 640 x 464, 29.97 fps, video: DivX 3 Low-Motion, audio: MPEG-1 Layer 3 (stereo, 32000 Hz)
You can see in my example above the audio: MPEG-1 Layer 3 (stereo, 32000 Hz) portion. This means the movie's audio was encoded with MP3.
Now you can simply use
# mplayer -dumpaudio -dumpfile mp3name.mp3 moviefile.avi
To get your MP3 file.
Method 2: Dumping to ac3 then converting to mp3
Usually when trying to extract the audio off of DVDs you end up with an ac3 file. This is fine, but you'll have to convert it to an MP3 from here. This is where ffmpeg comes in handy.
First we need to dump the audio:
mplayer -dumpaudio -dumpfile audio.ac3 dvd://1
For more information on playing DVDs or to change chapters see the mplayer manual.
Note: This may take a while. It takes a least 5 minutes for me.
Now convert your ac3 file into an MP3.
ffmpeg -i audio.ac3 -ab 128 audio.mp3
Méthode 3: Utiliser mplayer pour extraire la piste audio en PCM WAV et la convertir en MP3
Cela fonctionne avec quasiment tous les types de videos, y compris avec les formats matroska (MKV) et OGG-VORBIS (OGM)
- Extraction de la piste audio en PCM WAV
mplayer -vc dummy -vo null -ao pcm:file=output.wav,fast -af format=s16le video.mkv
- Encodage du fichier WAV
- En MP3
lame -h -b224 --tt 'Français pour une nuit' --ta 'Metallica' --ty '2009' --tl 'Live - Nimes 2009' --tg 'Metal' --ti 'Metallica - Francais Pour Une Nuit France Nimes 2009.jpg' metallica.wav 'Metallica - Francais Pour Une Nuit France Nimes 2009.mp3'
- En flac
flac --best -T 'TITLE=Français pour une nuit' -T 'ARTIST=Metallica' -T 'ALBUM=Live - Nimes 2009' -T 'GENRE=Metal' -T 'DATE=2009' --picture='Metallica - Francais Pour Une Nuit France Nimes 2009.jpg' metallica.wav
- En MP3
- Suppression du fichier wav
rm output.wav