Playing YouTube Flash videos on a DVD player

When watching long YouTube videos such as Google TechTalks, I rather like to watch them on TV through a DVD player with a USB thumb-drive input (See the figure). So I have struggled to convert Flash .flv files downloaded from YouTube into AVI files playable on my DVD player.


Pioneer DV-510K from http://www.multiregionupgrades.com/upgrades/pioneer/dv510.htm
Figure: Pioneer DV-510K.

After a survey, the points turn out to be

  • Make your converted AVI file DivX-compatible. This is because DivX seems to be the de fact standard video codec supported by any regular DVD players. XviD, an open version of DivX, seems not playable on commercial DVD players (at least on my DVD player).
  • Use ffmpeg command for conversion. It did the best job among other programs in my case. Other than ffmpeg, I have tried avidemux (a GUI video editor), mencoder (a command line movie encoder), and VLC (internally using ffmpeg in its conversion facilities). Both are useful programs. However, ffmpeg is my most favorite due to its capabilities and flexibility.

So, converting Flash .flv files into AVI files with DivX video codec is crucial. Also, note that, with the following method, the input video format is actually arbitrary as long as it is supported by ffmpeg. Therefore, you can watch various kinds of video files on a DVD player after the DivX conversion.

Method

First, install ffmpeg under Ubuntu as

$ sudo apt-get install ffmpeg

Then, here is a working command that converts video.flv into video.avi with DivX codec playable on DVD players:

$ ffmpeg -i video.flv -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -ab 128k -vtag divx video.avi

The majority of the options comes from the manual of ffmpeg command (Try man ffmpeg.). Although MPEG-4 with B-frames is already compatible with DivX codec, giving the -vtag divx option seems mandatory for DVD players to recognize the DivX video.

To check the metadata of the file before and after conversion, you can use file command:

$ file video.flv video.avi
video.flv:  Macromedia Flash Video
video.avi: RIFF (little-endian) data, AVI, 320 x 240, ~30 fps, video: DivX 4, audio: MPEG-1 Layer 1 or 2 (mono, 22050 Hz)

I copy the AVI file into a USB thumb-drive, insert the drive into a DVD player, and watch the video on my TV set. Hope it helps!

Resource

I would like to post a Shell script that I am using for convenience.
2divx

#!/bin/sh

if [ $# != 1 ]; then
    echo "Usage: $0 <video_file>"
    exit 1
fi

ffmpeg -i $1 -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -ab 128k -vtag divx ${1%.*}.avi

exit 0

First, make sure that you have ffmpeg command already installed. Make the script executable by chmod. Then, run the script with a single argument (an input video file name). It will generate a DivX output file with a .avi extension.

$ chmod 775 2divx
$ ./2divx video.flv
...
$ ls video.*
video.avi video.flv

Appendix: Conversion with lower quality

I have observed that the DivX codec bloats the original Flash file significantly. If you don't care about losing the quality, you may convert a Flash file into a smaller file in MPEG-1 codec still playable on regular DVD players:

$ ffmpeg -i video.flv video.mpeg

Here is a comparison using a music video with 320x240 and 5m20s.

$ ls -l video.*
-rw-r--r-- 1 yoi yoi 23283746 2010-02-14 12:41 video.avi
-rw-r--r-- 1 yoi yoi 13273466 2009-06-09 20:10 video.flv
-rw-r--r-- 1 yoi yoi 10842112 2010-02-14 12:10 video.mpeg
$ file video.*
video.avi: RIFF (little-endian) data, AVI, 320 x 240, ~30 fps, video: DivX 4, audio: MPEG-1 Layer 1 or 2 (mono, 22050 Hz)
video.flv:  Macromedia Flash Video
video.mpeg: MPEG sequence, v1, system multiplex