Transcode and stream DV to mpeg4 via firewire using VLC and Ubuntu 8.04 (Hardy Heron)

Well kids are you ready for todays lesson in transcoding DV video. So first you need a decent machine. I’m using a P4 2.4Ghz oldie that has Firewire on-board and am chewing up 50% CPU for NTSC encoding. Then you need to get Ubuntu 8.04 installed. Once that’s done use the following command to install vlc (Video Lan Client):
sudo apt-get install vlc
Then either follow this guide or if you’re using 8.04 (Hardy Heron) ONLY, use the following command to add Medibuntu to your repository sources.list:
sudo wget -O /etc/apt/sources.list.d/medibuntu.list
followed by
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
to add the GPG key for Medibuntu Repository. You may be asked to accept this package even though it cannot be authenticated. This is normal; typing “Yes” means you trust Medibuntu.
Now do the following commands to get libdvdcss and other codecs installed on your machine:
sudo apt-get install libdvdcss2
sudo apt-get install w32codecs (for i386 architecture) OR
sudo apt-get install w64codecs (for amd64 architecture)

Now that we have all the goodies installed and ready to go you can go ahead and connect that DV camera to your Ubuntu box using Firewire. Make sure it’s in Camera mode (NOT VCR) and open up a command line and type in the following command to get the encoder setup:
sudo -i (This will put you in superuser root account)
cat /dev/dv1394/0 | vlc - :demux=rawdv -I dummy --sout '#transcode{vcodec=mp4v,vb=1024,acodec=mpga,ab=192,scale=1,width=720,height=480}:duplicate{dst=std{access=udp,mux=ts,dst=IPAddressofDestinationMachine:PortNumber}}'

You could also run the above command from your user account by adding sudo infront of it and supply your password followed by Enter key.

The above command (in case you’re wondering) will literally open device zero on the firewire chain and redirect it’s raw output into the VLC program. VLC is told to accept input from a pipe in rawdv format and to transcode it to mpeg4 Video @ 1Mb/s with mpeg1-layer3 audio @ 192 Kb/s.

Once the above command is running you’ll need to go to your receiving machine (the machine who’s IP you supplied in the command above), run VLC and from the File menu choose “Open Network Stream” and go with the default UDP/RTP on port 1234 (or whatever port you chose in the encoder command line).

Another neat thing you can do with your new found opensource goody bag is capture DV from your camera/settop box and save it in mpeg4 format for archival purposes (or mpeg2 for editing maybe). I’m not gonna get into the details, but assuming you’ve done the above commands, skip the encoder command and issue the following command to get your DV stream saved:
sudo -i
cat /dev/dv1394/0 | ffmpeg -f dv -i - -f mp4 -s 720x480 -vcodec mpeg4 -acodec aac -ab 128 -ar 44100 -deinterlace -b 3000k -y yourfilename.mp4

This command will take rawdv from the camera, pass it to ffmpeg, which will chew on it and spit it out as mpeg4 video @ 3Mb/s with AAC audio @ 128Kb/s into a file named yourfilename.mp4 (if the file exists it will overwrite it). Stopping is accomplished by CTRL-C. More info on this command can be found on ffmpeg’s man page.

Have Fun….

, , , , , ,

6 responses to “Transcode and stream DV to mpeg4 via firewire using VLC and Ubuntu 8.04 (Hardy Heron)”

  1. Hi Many
    i tried your suggestion but with no luck again. i went back to a clean install of ubuntu studio 8.04 and followed the steps from this blog and everything installed successfully. however, when i tried the VLC command i get this message in the terminal:

    root@LiveServer:~# cat /dev/dv1394/0 | vlc – :demus=rawdv -I dummy –sout ‘#transcode{vcodec=mp4v,vb=1024,acodec=mpga,ab=192,scale=1,width=720,height=480}:duplicate{dst=std{access=dup,mux=ts,dst=}}’
    VLC media player 0.8.6e Janus
    starting VLC root wrapper… using UID 1000 (liveserver)
    [00000295] dummy interface: using the dummy interface module…
    [00000314] main private error: no sout access module matched “dup”
    [00000312] stream_out_standard private error: no suitable sout access module for `dup/ts://′
    [00000310] stream_out_duplicate private error: no destination given
    [00000307] stream_out_transcode private error: cannot create chain
    [00000306] main stream output error: stream chain failed for `transcode{vcodec=mp4v,vb=1024,acodec=mpga,ab=192,scale=1,width=720,height=480}:duplicate{dst=std{access=dup,mux=ts,dst=}}’
    [00000304] main input error: cannot start stream output instance, aborting
    [00000289] main playlist: nothing to play

    any ideas what could be the problem?

    When i use your ffmpeg command everything works fine. i only had to change the acc codec to mp3.

    i start to think that it is really stupid from vlc developers to use v4l.


  2. Oh sh*t, i went over the command again and found my typing errors. it works fine now… thank you so much for this post.

  3. although it says:
    AC ECB marker is absent pos=65

    does that matter?

  4. Ok. I bought 2 different firewire cards, and tested on one computer. Ubuntu found one of the cards, but nothing to play…
    cat: /dev/dv1394/0: No such file or directory
    I installed the whole thing again on a Dell Precision with Firewire on the motherboard. Still the same error message. You should have a link to some page troubleshooting the 1394 device.

  5. A little trial & error plus some reading through ffmpeg -h led me to this modified command
    cat /dev/dv1394/0 | ffmpeg -f dv -i – -f mp4 -s 720×480 -vcodec mpeg4 -aspect 16:9 -ab 128k -ar 48000 -deinterlace -sameq -y ffmpegmp4.mp4

    I also made a shell file with this in it to do further editing in avidemux.

    cat /dev/dv1394/0 | ffmpeg -f dv -i – -f mp4 -s 720×480 -vcodec mpeg4 -aspect 16:9 -ab 128k -ar 48000 -deinterlace -sameq -y ffmpegmp4.mp4 && avidemux2_gtk –load `ls -t | awk '{if(NR==1)print$1}'`

    no super user required so far since the first commands I tried. Not sure if that will hold true after reboot.

  6. After a little more trial & error I found this works better for loading the resulting capture into avidemux

    cat /dev/dv1394/0 | ffmpeg -f dvd -i – -s 720×480 -aspect 16:9 -intra -ab 384k -ar 48000 -deinterlace -sameq -y testdvd.avi | sleep 3 && avidemux2_gtk –load `ls -t | awk '{if(NR==1)print$1}'`

    ffmpeg needs time to exit properly I guess.

Leave a Reply