Backtrack Linux

How To Convert Video To Audio/Mp3 In Linux Or Backtrack Os From Terminal

Written by devendermahto
Hi To All The Mindbenders,
Today i Will Show you How to use ffmpeg to convert a video (an AVI or MP4 video, for example) to an MP3 that you can load on your MP3 player:


* FOR MP4 to MP3-use below command and learn from my results shown in Demo Section    ffmpeg -i video.mp4 -f mp3 -ab 192000 -vn music.mp3

DEMO

root@bt:~/Desktop# ffmpeg -i video2.mp4 filename.mp3
FFmpeg version SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: –extra-version=4:0.5.9-0ubuntu0.10.04.1 –prefix=/usr –enable-avfilter –enable-avfilter-lavf –enable-vdpau –enable-bzlib –enable-libgsm –enable-libschroedinger –enable-libspeex –enable-libtheora –enable-libvorbis –enable-pthreads –enable-zlib –disable-stripping –disable-vhook –enable-runtime-cpudetect –enable-gpl –enable-postproc –enable-swscale –enable-x11grab –enable-libdc1394 –enable-shared –disable-static
libavutil     49.15. 0 / 49.15. 0
libavcodec    52.20. 1 / 52.20. 1
libavformat   52.31. 0 / 52.31. 0
libavdevice   52. 1. 0 / 52. 1. 0
libavfilter    0. 4. 0 /  0. 4. 0
libswscale     0. 7. 1 /  0. 7. 1
libpostproc   51. 2. 0 / 51. 2. 0
built on Jun 12 2012 16:27:34, gcc: 4.4.3

Seems stream 0 codec frame rate differs from container frame rate: 59.94 (60000/1001) -> 29.97 (30000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from ‘video2.mp4’:
Duration: 00:04:14.90, start: 0.000000, bitrate: 1645 kb/s
Stream #0.0(und): Video: h264, yuv420p, 1280×720, 29.97 tbr, 29.97 tbn, 59.94 tbc
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16
Output #0, mp3, to ‘filename.mp3’:
Stream #0.0(und): Audio: libmp3lame, 44100 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Press [q] to stop encoding
size=    1992kB time=254.93 bitrate=  64.0kbits/s
video:0kB audio:1992kB global headers:0kB muxing overhead 0.001569%
root@bt:~/Desktop#


* FOR AVI to MP3-use below command and learn from my results shown in Demo Section    ffmpeg -i video.flv devendermahto.mp3

DEMO

root@bt:~/Desktop# ffmpeg -i video.flv devendermahto.mp3
FFmpeg version SVN-r0.5.9-4:0.5.9-0ubuntu0.10.04.1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: –extra-version=4:0.5.9-0ubuntu0.10.04.1 –prefix=/usr –enable-avfilter –enable-avfilter-lavf –enable-vdpau –enable-bzlib –enable-libgsm –enable-libschroedinger –enable-libspeex –enable-libtheora –enable-libvorbis –enable-pthreads –enable-zlib –disable-stripping –disable-vhook –enable-runtime-cpudetect –enable-gpl –enable-postproc –enable-swscale –enable-x11grab –enable-libdc1394 –enable-shared –disable-static
libavutil     49.15. 0 / 49.15. 0
libavcodec    52.20. 1 / 52.20. 1
libavformat   52.31. 0 / 52.31. 0
libavdevice   52. 1. 0 / 52. 1. 0
libavfilter    0. 4. 0 /  0. 4. 0
libswscale     0. 7. 1 /  0. 7. 1
libpostproc   51. 2. 0 / 51. 2. 0
built on Jun 12 2012 16:27:34, gcc: 4.4.3

Seems stream 0 codec frame rate differs from container frame rate: 60.00 (60/1) -> 29.97 (30000/1001)
Input #0, flv, from ‘video.flv’:
Duration: 00:04:14.33, start: 0.000000, bitrate: 235 kb/s
Stream #0.0: Video: h264, yuv420p, 320×240 [PAR 1:1 DAR 4:3], 235 kb/s, 29.97 tbr, 1k tbn, 60 tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16
Output #0, mp3, to ‘devendermahto.mp3’:
Stream #0.0: Audio: libmp3lame, 44100 Hz, stereo, s16, 64 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Press [q] to stop encoding
size=    1991kB time=254.90 bitrate=  64.0kbits/s
video:0kB audio:1991kB global headers:0kB muxing overhead 0.001569%
root@bt:~/Desktop#

But there’s a catch: You have to have ffmpeg and the libavcode-unstripped-52 packages installed on your computer. The problem is that second package is available in the multiverse respository only. To enable the multiverse repository, select Administration from the System menu, then Software Sources. In the Ubuntu Software tab of the Software Sources dialog box, select the check box that reads Software Restricted By Copyright Or Legal Issues (Multiverse). Click the Close button when you’re done.
After you’ve enabled the multiverse repository, you can install the ffmpeg and libavcodec-unstripped-52 packages from a Terminal window with the following command:

  sudo apt-get install ffmpeg libavcodec-unstripped-52

Now, let’s go back to the options that I used with the ffmpeg command at the beginning of the article. The -i video.mp4 option is easy: it identifies the path to the input file. The -f mp3 option tells ffmpeg that we want the output format to be MP3. The -ab 192000 bit tells ffmpeg that we want our MP3 encoded at 192Kbps. The -vn option means “No video in the output”. Finally, “music.mp3” is just the name we want to give to the output file.
That’s it! Now, if you could just figure out how to download video from popular sites on the Internet, you could extract MP3 audio from your downloads!

SCREENSHOTS
1.installing ffmpeg codecs
2.FLV-2-MP3
3.MP4-2-MP3

===(Next Is What…?)==

 

About the author

devendermahto

Leave a Comment