/* Adzra */

Blog Free Music, Video, MP3

Friday, July 11, 2008

How to download and convert YouTube video to MPG/AVI in Ubuntu?

Every once in a while, you may come across some videos on YouTube-the popular free video sharing service. You may enjoy the videos more or less but sometimes, just sometimes, you come across a video you really need to have on your hard drive and to watch over and over again, every time you feel the need. Unfortunately, YouTube seems to discourage its users from downloading the videos. This can get rather annoying because you'll need to save a bookmark with the video url, load it in your browser every time you want to re-watch it, wait until it's loaded and so on. So why get through all this trouble, when you can easily download the file in Flash Video format (FLV), convert it into mpeg4 or xvid video with mp3 audio and watch it on your PC or even on your mobile phone?

However, the standard ffmpeg package is pretty useless since it doesn't offer support for mp3 so you'll have to go through a painful process first in order to encode your videos with mp3 audio. Before we start, your Ubuntu system needs to have the c compilers, patch tools and standard devel packages installed. It also needs to have multiverse and universe repositories enabled. And to make things easier, you'll need to have a password on the root account. As this is the easiest part, we'll start with it.

Open a terminal and type:

CODE

$ sudo passwd root

Enter a password and switch to the super user account by typing:

CODE

$ su -

You will now have a super user bash terminal (#). Copy the following command and paste it into the super user terminal to install the needed libraries:

CODE

# apt-get install quilt libsdl1.2-dev libogg-dev libvorbis-dev liba52-dev libdts-dev libimlib2-dev texi2html libraw1394-dev libdc1394-13-dev libtheora-dev libgsm1-dev liblame-dev libxvidcore4-dev libfaac-dev libfaad2-dev

Go to a build directory. Since you're logged in as root, use the default build directory:

CODE

# cd /usr/local/srcNow

get the ffmpeg source package:

CODE

# apt-get source ffmpegGet the patches for ffmpeg and apply them. Click HERE and save the file in /usr/local/src/:

CODE

# cd ffmpeg-0.cvs20060823

# bzcat ../ffmpeg-0.cvs20060823_enable_amr.patch.bz2 patch -p1

You should see something like:

CODE

root:/usr/local/src/ffmpeg-0.cvs20060823# bzcat ../ffmpeg-0.cvs20060823_enable_amr.patch.bz2 patch -p1

patching file debian/rules

patching file libavcodec/amr_float/decoder.c

patching file libavcodec/amr_float/encoder.c

patching file libavcodec/amr_float/interf_dec.c

patching file libavcodec/amr_float/interf_dec.h

patching file libavcodec/amr_float/interf_enc.c

etc..

Now build the deb packages:

CODE

# DEB_BUILD_OPTIONS="risky" dpkg-buildpackage

Go back to the src directory and install the resulting deb packages:

CODE

# cd ..# dpkg -i ffmpeg_0.cvs20060823-3.1ubuntu1_i386.deb libavcodec0d_0.cvs20060823-3.1ubuntu1_i386.deb libavformat0d_0.cvs20060823-3.1ubuntu1_i386.deb libpostproc0d_0.cvs20060823-3.1ubuntu1_i386.deb

Open /etc/apt/preferences using your favorite text editor and add the following lines:

CODE

Package: ffmpeg Pin: version 0.cvs20060823-3.1ubuntu1 Pin-Priority: 1001

Package: libavcodec0d Pin: version 0.cvs20060823-3.1ubuntu1 Pin-Priority: 1001

Package: libavformat0d Pin: version 0.cvs20060823-3.1ubuntu1 Pin-Priority: 1001

Package: libpostproc0d Pin: version 0.cvs20060823-3.1ubuntu1 Pin-Priority: 1001

Get the youtube-dl script which allows you to download YouTube movies in flv format, to your hard drive.

Click HERE and download the youtube-dl script anywhere on your hard drive. Now, from the root termina, run these commands to make the script available for all users on the Ubuntu machine:

CODE

# cd /where/you/downloaded/the/script

# chmod +x youtube-dl

# mv youtube-dl /usr/local/bin

Download movies from YouTube by using the script:

CODE

$ youtube-dl youtube.http.address.while.viewing.video

The movie will be saved to something like I_KRmU2dO2M.flv

Finally, convert .FLV files into MPEG:

CODE

ffmpeg -i I_KRmU2dO2M.flv -ab 56 -ar 22050 -b 500 -s 320x240 video.mpg

Convert .FLV into XviD .AVI with MP3 Audio:

CODE

ffmpeg -i I_KRmU2dO2M.flv -ab 56 -ar 22050 -b 500 -s 320x240 -vcodec xvid -acodec mp3 video.avi

Enjoy! source : http://www.brothersoft.com/

Labels: , ,

posted by Adzra Ramadhani at 10:06 PM

0 Comments:

Post a Comment

<< Home