Youtube video to mp3

Assume you want to download just the music of below video on Youtube, so you can listen to the music on your phone, while you are on the road.

Here are the necessary steps on the command line:

youtube-dl www.youtube.com/watch?v=aHjpOzsQ9YI
mv Crystallize\ -\ Lindsey\ Stirling\ \(Dubstep\ Violin\ Original\ Song\)-aHjpOzsQ9YI.mp4 LindseyStirling-Crystallize.mp4
avconv -i LindseyStirling-Crystallize.mp4 LindseyStirling-Crystallize.mp3

To cut only a portion of the video use the following command (ss is start time, t is duration):

avconv -i file.mp4 -ss 00:02:23 -t 00:09:44 file.mp3

One can use ffmpeg instead of avconv. ffmpeg was initially written by this incredible French Fabrice Bellard, who is also the author of tcc.

avconv or ffmpeg on Ubuntu do not come with MP3 support by default. Sou you have to install this by

apt-get install libavcodec-extra-53

Here are the relevant versions involved:

$ youtube-dl --version
2013.12.17.2

$ avconv -version
avconv version 0.8.10-4:0.8.10-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
  built on Feb  6 2014 20:56:59 with gcc 4.6.3
avconv 0.8.10-4:0.8.10-0ubuntu0.12.04.1
libavutil    51. 22. 2 / 51. 22. 2
libavcodec   53. 35. 0 / 53. 35. 0
libavformat  53. 21. 1 / 53. 21. 1
libavdevice  53.  2. 0 / 53.  2. 0
libavfilter   2. 15. 0 /  2. 15. 0
libswscale    2.  1. 0 /  2.  1. 0
libpostproc  52.  0. 0 / 52.  0. 0

See also: superuser: How can I convert MP4 video to MP3 audio with ffmpeg?

For moving the MP3 file to my Android phone I use SSHelper, see also ssh and rsync for Android.

Advertisements

One thought on “Youtube video to mp3

  1. Pingback: Installing Ubuntu 14.04 Server Edition | Elmar Klausmeier's Weblog

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s