Convert YouTube Videos

So, you need to extract an audio WAV or MP3 file from a YouTube video? Or maybe create a portable AVI or MPEG video from a YouTube posting? This article will show you how.

Download the Original Flash Video File

First, you will need a file to convert. Use one of the many online video downloaders to extract an FLV from a YouTube (or MetaCafe, iFilm, etc) URL. Here are a few:

When you download the file from the specific URL, rename the file to include a .flv extention. Most of the web based download tools give you a file named something like "get_video".

bash$ mv get_video myvideo.flv

FYI: you can play flv files with the VideoLAN media player (VLC).

Install FFmpeg and Media Codecs

FFmpeg is a collection of libraries and tools that allow you to convert media files. Make sure you have ffmpeg installed with access to the proper codecs. Fedora and RedHat users can use for src and binary RPMs. Ubuntu and Debian users can install ffmpeg with apt-get. Or, if you download the source code for ffmpeg, here are the options the Livna RPM for Fedora Code 6 are compiled with:

bash$ ffmpeg -version
FFmpeg version SVN-r8876, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --prefix=/usr --incdir=/usr/include/ffmpeg --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --arch=x86_32 --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables --enable-libmp3lame --enable-libogg --enable-libtheora --enable-libvorbis --enable-libfaad --enable-libfaac --enable-libgsm --enable-xvid --enable-x264 --enable-liba52 --enable-liba52bin --enable-libdts --enable-pp --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-opts --disable-strip 
libavutil version: 49.4.0
libavcodec version: 51.40.4
libavformat version: 51.12.1
built on May  3 2007 11:15:43, gcc: 4.1.1 20070105 (Red Hat 4.1.1-51)
ffmpeg      SVN-r8876
libavutil   3212288
libavcodec  3352580
libavformat 3345409

If you need codec libaries, download them from MPlayer’s Codec Releases.

bash$ wget
bash$ tar -xjvf all-20061022.tar.bz2
bash$ sudo mkdir -p /usr/lib/codecs
bash$ sudo cp all-20061022/* /usr/lib/codecs/

Use FFmpeg to Convert Files

This is how you convert the flv to various audio and video formats:

# FLV to WAV -ac 2 is stereo, change to 1 for mono audio
ffmpeg -title "Custom Title" -i myvideo.flv -ac 2 -y myvideo.wav
# FLV to MP3  -ab 128 is the mp3 bit rate
ffmpeg -title "Custom Title" -i myvideo.flv -acodec mp3 -ac 2 -ab 128 -vn -y myvideo.mp3
# FLV to MPEG -s is geometry of video
ffmpeg -title "Custom Title" -i myvideo.flv -s 320x240 -y myvideo.mpeg
# FLV to AVI -ac 2 is stereo, change to 1 for mono audio
ffmpeg -title "Custom Title" -i myvideo.flv -ac 2 -y myvideo.avi