Encoding DVD into HQ flash video using ffmpeg

| No Comments | No TrackBacks

As you might know, I despise flash as a way to deliver video, but just have to use it if you want to publish videos for poor M$ excuse for web browser. I don't like DVD either, mostly because it's encrypted, but let's finish with rants here.

So, I have DVD in my hand and need high quality flv file from it with readable slides if at all possible. You really don't want to encode video file more than once since it's already in mpeg format, and event two times re-encode could make your slides unreadable.

First step is to make local copy of whole disk (which will take 4+ Gb) so I can re-try encoding without listening to spinning DVD all the time and mount it:

$ dd if=/dev/cdrom of=dvd.iso
$ mkdir mnt
$ sudo mount dvd.iso mnt -o loop
$ ls -al mnt/
total 10
dr-xr-xr-x 4 4294967295 4294967295  136 2009-09-30 20:45 .
drwxr-xr-x 5 dpavlin    dpavlin    4096 2009-10-15 22:01 ..
dr-xr-xr-x 2 4294967295 4294967295   40 2009-09-30 17:25 AUDIO_TS
dr-xr-xr-x 2 4294967295 4294967295  560 2009-09-30 18:45 VIDEO_TS
Looks good so far. However, to add insult in injury, video is in multiple files (it's 60 minute lecture):
dpavlin@klin:/rest/iso/Zimbardo$ ls -al mnt/VIDEO_TS/
total 4093324
dr-xr-xr-x 2 4294967295 4294967295        560 2009-09-30 18:45 .
dr-xr-xr-x 4 4294967295 4294967295        136 2009-09-30 20:45 ..
-r--r--r-- 1 4294967295 4294967295      14336 2009-09-30 18:45 VIDEO_TS.BUP
-r--r--r-- 1 4294967295 4294967295      14336 2009-09-30 18:45 VIDEO_TS.IFO
-r--r--r-- 1 4294967295 4294967295     157696 2009-09-30 18:41 VIDEO_TS.VOB
-r--r--r-- 1 4294967295 4294967295      73728 2009-09-30 18:45 VTS_01_0.BUP
-r--r--r-- 1 4294967295 4294967295      73728 2009-09-30 18:45 VTS_01_0.IFO
-r--r--r-- 1 4294967295 4294967295      12288 2009-09-30 18:41 VTS_01_0.VOB
-r--r--r-- 1 4294967295 4294967295 1073565696 2009-09-30 18:42 VTS_01_1.VOB
-r--r--r-- 1 4294967295 4294967295 1073565696 2009-09-30 18:43 VTS_01_2.VOB
-r--r--r-- 1 4294967295 4294967295 1073565696 2009-09-30 18:45 VTS_01_3.VOB
-r--r--r-- 1 4294967295 4294967295  970516480 2009-09-30 18:45 VTS_01_4.VOB
So, I created following script to help me with it:
#!/bin/sh -x

input="`ls mnt/VIDEO_TS/VTS_01_[1234].VOB | sed 's/^/-i /'`"

out_flv="lecture.flv"

format="-ab 48k -ar 44100 -vcodec flv -b 400k -g 160 -cmp 3 -subcmp 3 -mbd 2 -flags aic+cbp+mv0+mv4 -trellis 1 -deinterlace"

ffmpeg $input $limit -pass 1 $format -y $out_flv || exit
ffmpeg $input $limit -pass 2 $format -y $out_flv || exit
It does two pass encoding, preserving most of audio fidelity while creating stream which takes about 50Kb/s to stream smoothly. You will notice that I didn't encode VTS_01_0.VOB which isn't really a just a subtitle stub:
$ ffplay mnt/VIDEO_TS/VTS_01_0.VOB
Input #0, mpeg, from 'mnt/VIDEO_TS/VTS_01_0.VOB':
  Duration: N/A, start: 0.360000, bitrate: N/A
    Stream #0.0[0x1e0]: Video: mpeg2video, yuv420p, 720x576 [PAR 16:15 DAR 4:3], 7000 kb/s, 25 
    Stream #0.1[0x20]: Subtitle: dvdsub

If you are recoding and editing video which will later be on Internet, please don't use fancy transitions. There is no hope for those to look good after re-encoding. This video had 3D box rotating effect (although simple fade would be enough) which turned into ugly blur, but other than that, it's perfectly readable.

No TrackBacks

TrackBack URL: http://blog.rot13.org/mt/mt-tb.cgi/661

Leave a comment

About this Entry

This page contains a single entry by Dobrica Pavlinušić published on October 16, 2009 5:50 PM.

ZFS does hierarchical management of disk space right was the previous entry in this blog.

DVB-T using mplayer in Zagreb is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

  • pics
OpenID accepted here Learn more about OpenID
Powered by Movable Type 5.04