Monday, December 30, 2013

Sample usage of transcoding using vlc, then genisoimage and wodim to write a dvd

Today I needed to write a dvd with some old family videos in it. The videos were obtained from my Sony Handycam. They were .MPG files, but the problem was they were too large to fit in a dvd.

So, to reduce their size without changing the quality, I decided to transcode them using vlc. I had no idea how to do it. So I fired up vlc from a terminal and after exploring some menu items, I transcoded one of the files to .mp4. The size got reduced by more than half. Great! Now I had to find a corresponding command line form of the same action for automating it for transcoding all of the 36 files I had.

So, I looked at the terminal dump of whatever vlc had done so far, and then googled around a little, and came up with this solution (for my case):

for i in `seq -w 01 36`; do 
  cvlc ~/Videos/HomeVideos/2011.10.05/M2U000$i.MPG
       --sout '#transcode{
                  vcodec=h264,vb=0,scale=0,
                  acodec=mpga,ab=128,
                  channels=2,samplerate=44100
               }:std{access=file,mux=mp4,dst='./$i.mp4'}'
       vlc://quit;
done


(BTW, what I actually ran was the above code all in a single loong line. I just formatted the above code to look nice and be more understandable. I am not sure whether the code would work if formatted like above. Too lazy to try now.)

The vlc://quit was to make vlc quit after transcoding each file. Otherwise I had to press Ctrl-C after each file was transcoded.

Next I made an iso image out of the transcoded files with the genisoimage as follows:

genisoimage -o homevideos_2011.10.05.iso \
            -p "Santanu" -V "HomeVideos_2011.10.05" -publisher "Santanu" \
            ./converted/


Then I wrote the resulting iso file to a blank dvd using wodim as follows:

wodim -v -eject speed=4 dev=/dev/dvdrw driveropts=burnfree homevideos.iso 



Post a Comment