There are any number of utilities that make downloading videos from YouTube and other video sharing websites incredibly easy. Some of them simply add the appropriate download links to the actual YouTube page, while others scan video pages, then provide notifications when they find videos they can handle. There are websites on the Internet to accomplish the same thing. Simply put in the URL of the video, and the website gives you a link to download the actual file. And finally there are specialty programs that accomplish the same thing from the Terminal, such as rtmpdump, get-flash-videos and others.
Of course, once you’ve downloaded the video, you may find yourself stuck as to what to do with it. Many, if not most, of the videos stored on the Web are in Flash Video format, which has the .flv extension. This is just a container, and the audio and video within can be many different formats. You’ll typically see .flv videos using H264 video, but older Sorenson Spark codecs are also used. For audio, mp3 is typical, but newer versions also support AAC audio. Sometimes playing these files back on desktop computer software can be challenging, but most current players such as VLC and MPlayer have no trouble. Converting these Flash Video files, on the other hand, could potentially be a challenge. In this guide, I will attempt to show just how easy it can be, with the right tools. I’ll mainly be using FFmpeg, a free and open source video recording, converting and streaming utility. I use Ubuntu Linux, so everything I type will be aimed at similar users, although the tools and commands should translate to Windows or Mac, although there may be slight differences.
Okay, so you’ve downloaded a .flv from some random website, and you want to watch the video on your DVD player, which supports Divx files. This is pretty easy. We’ll assume for a moment that your video is named simply video.flv and that it is in your Home directory. If not, you’ll need to “cd” to wherever the file is for these commands to work.
The first thing we’ll want to do is find out exactly what codecs are used for the audio and video streams within the video file. You can probably just use “Get Info” or access the file’s Properties dialog, but that information isn’t always as specific as you’ll need. So I use a simple command in FFmpeg. Again, assuming the name of the file is video.flv, the command is as follows:
ffmpeg -i video.flv
You should get a bunch of information about the file, including length, name, other attributes, and most importantly, any streams contained within, such as audio, video and subtitles. This article will only deal with audio and video, and those two lines should look something like this:
Stream #0.0: Video: h264, yuv420p, 854×480, 560 kb/s, 59.75 tbr, 1k tbn, 59.83 tbc
Stream #0.1: Audio: aac, 44100 Hz, stereo, s16, 95 kb/s
Above that, in list format, we’ll find other attributes, such as framerate and duration.
Note: I cut out a couple things from the above video line to make it a bit shorter, but the important info is still there (we’re really just looking for codec, dimensions and bitrate).
As you can see, this file uses the H264 codec for video and AAC for audio. Because of this, both will need to be re-encoded. For encoding video for playback on my Philips DVD player, which is Divx-capable, I use the following command:
ffmpeg -i video.flv -f avi -vcodec mpeg4 -b 1500k -s 720×404 -ab 128k -vtag divx video.avi
A few notes about the above command. The “-b 1500k” command tells ffmpeg to strive for 1500 kbps for the video bitrate. You’ll need to mess with this to get a quality setting you like. Similarly, the “-ab 128k” tells ffmpeg to use 128 kbps as the audio bitrate. For .avi files, ffmpeg uses MP2 audio by default, which is fine for our purposes. As far as resizing goes, in the above command I resized the picture using the “-s 720×404” command. I did this because the source video’s resolution of 854×480 is larger than my old TV can display, so resizing it brought the picture down in resolution (and made the file smaller as well). Finally, since ffmpeg doesn’t use the actual Divx codec, many Divx-capable DVD players would choke on our converted file. However, the mpeg4 codec we did use is fine. So we used the “-vtag divx” command, which has ffmpeg set that flag so that the file appears as if it uses Divx, and because of this it should play fine.
Once the video has converted, simply burn it to a blank CD or DVD, and your Divx-capable DVD player should play it without any problems!