Skip to content. | Skip to navigation

Personal tools
Log in Register
Social justice and environmental video from the Asia Pacific
Sections
Personal tools
You are here: Home Members Musicman Tutorial - Transcoding in Linux using Handbrake
You are here: Home Members Musicman Tutorial - Transcoding in Linux using Handbrake
Document Actions

Tutorial - Transcoding in Linux using Handbrake

by Musicman last modified May 10, 2012 07:48 AM
2.98095238095
No rating set
In this quick howto, I show how to transcode a DVD to EngageMedia specs using Handbrake in Ubuntu Feisty.


Requirements

Handbrake is "an open-source, GPL-licensed, multiplatform, multithreaded DVD to MPEG-4 converter, available for MacOS X, Linux and Windows. On linux, it is a command line tool." You can download it from the Handbrake Download page. The version used in this tutorial was 0.9.2

Ffmpeg can be installed using Synaptic in Ubuntu, most other package management tools in other brands of linux have some version of it, or it can be downloaded from their repository on the mplayer site. The ffmpeg developers note that "new, official 'releases' are few and far between. In short, if you want to work with FFmpeg, you are advised to go along with SVN development rather than relying on formal releases. SVN snapshots work really well 99% of the time so people are not afraid to use them."

Lame is similarly available in most package managers on most brands of linux. Otherwise, it can be downloaded as a tarball from the lame site or the source can be found on sourceforge.

Howto encode to xVid/mp3

  1. Extract the tgz file to where you want to run it from. I use /home/user/handbrake and then move the resulting files to somewhere more sensible like /data/:
    datakid@boxen:~/handbrake$tar -zxf HandBrakeCLI-0.9.2-Linux_i386.tar.gz
    You should then end up with a file called HandBrakeCLI in your folder
  2. You can use the command:
    datakid@boxen:~/handbrake$ ./HandBrakeCLI -i /media/cdrom/video_ts -t 0
    to see what titles and chapters are available on your DVD. Here is a sample output:
    Scanning title 1 of 1...

    + title 1:
    + vts 1, ttn 1, cells 0->121 (1125931 blocks)
    + duration: 01:05:07
    + size: 704x576, aspect: 1.33, 25.000 fps
    + autocrop: 0/2/0/0
    + chapters:
    + 1: cells 0->7, 74756 blocks, duration 00:04:19
    + 2: cells 8->15, 74278 blocks, duration 00:04:00
    + 3: cells 16->23, 74251 blocks, duration 00:04:27
    + 4: cells 24->31, 74213 blocks, duration 00:04:13
    + 5: cells 32->39, 74575 blocks, duration 00:04:20
    + 6: cells 40->47, 74301 blocks, duration 00:04:17
    + 7: cells 48->55, 74405 blocks, duration 00:04:21
    + 8: cells 56->63, 74626 blocks, duration 00:04:13
    + 9: cells 64->71, 73998 blocks, duration 00:04:13
    + 10: cells 72->79, 74347 blocks, duration 00:04:09
    + 11: cells 80->87, 74214 blocks, duration 00:04:21
    + 12: cells 88->95, 74541 blocks, duration 00:04:17
    + 13: cells 96->103, 74267 blocks, duration 00:04:07
    + 14: cells 104->111, 74293 blocks, duration 00:04:21
    + 15: cells 112->119, 74325 blocks, duration 00:04:21
    + 16: cells 120->121, 10541 blocks, duration 00:01:08
    + audio tracks:
    + 1, Unknown (AC3) (2.0 ch), 48000Hz, 256000bps
    + subtitle tracks:
    HandBrake has exited.
  3. I like the idea of lots of small vids - they are easier to upload for one thing, so I am going to break them into chapters. I've used the EngageMedia recommended compression settings and the Handbrake Guide to come up with the following:
    datakid@boxen:~/handbrake$./HandBrakeCLI -t 1 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -B 128 -i /media/cdrom/VIDEO_TS -o title.avi

  4. This is exactly to the EngageMedia specs, you should be able to cut and paste the command, and put in your own input file and output file names for it to work for you. Here's a quick explanation of what it all does:
    • ./HandBrakeCLI calls the program from the current directory
    • -t 1 asks Handbrake to only transcode Title 1.
    • -e ffmpeg tells Handbrake to use the ffmpeg encoder. This is the default setting and can be excluded.
    • -b 1400 is the bit rate setting.
    • -r 25 is the frame rate setting.
    • -d tells HandBrake to make use a deinterlace filter.
    • -w 720 -l 576 are the width and height settings respectively.
    • -E lame sets the Audio encoder to be lame
    • -R 48 sets the sample rate to 48 kHz.
    • -B 128 sets the bit rate to 128 kbps. Note that this is also a default setting and can be excluded.
    • -i /media/cdrom/video_ts is the name of the input file and the directory it resides in.
    • -o title.avi is the output filename. The .avi is used by Handbrake to determine the container file type.

  5. I will note that running at the command line, I got output that looks like the following scroll past very fast:
    Encoding: task 1 of 1, 98.80 % (86.15 fps, avg 84.10 fps, ETA 00h00m14s)
    *** libdvdread: CHECK_VALUE failed in nav_read.c:207 ***
    *** for dsi->dsi_gi.zero1 == 0 ***

    *** libdvdread: CHECK_VALUE failed in nav_read.c:207 ***
    *** for dsi->dsi_gi.zero1 == 0 ***
    Despite the term "failed" appearing in the output, the video looks fine. And the output looks like this when it's done:
    Encoding: task 1 of 1, 99.84 % (86.67 fps, avg 84.13 fps, ETA 00h00m02s)
    Rip done!
    HandBrake has exited.

  6. Now, if you open up the new file in your favourite media browser, you can watch your newly created, transcoded vid. If everything looks good, and you decide that those are the settings that you would like to use, you can line up the rest of the DVD by running HandBrake repetitively using a semicolon as such:
    ./HandBrakeCLI -t 2 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter2.avi;
    ./HandBrakeCLI -t 3 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter3.avi;
    ./HandBrakeCLI -t 4 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter4.avi;
    ./HandBrakeCLI -t 5 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter5.avi;
    ./HandBrakeCLI -t 6 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter6.avi;
    ./HandBrakeCLI -t 7 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter7.avi;
    ./HandBrakeCLI -t 8 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter8.avi;
    ./HandBrakeCLI -t 9 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter9.avi;
    ./HandBrakeCLI -t 10 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter10.avi;
    ./HandBrakeCLI -t 11 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter11.avi;
    ./HandBrakeCLI -t 12 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter12.avi;
    ./HandBrakeCLI -t 13 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter13.avi;
    ./HandBrakeCLI -t 14 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter14.avi;
    ./HandBrakeCLI -t 15 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter15.avi;
    ./HandBrakeCLI -t 16 -e ffmpeg -b 1400 -r 25 -d -w 720 -l 576 -E lame -R 48 -i /media/cdrom/video_ts -o EarthDreamChapter16.avi
  7. I find now is a good time to go get some lunch, or go to bed - this little baby will take a while. Good Luck!