Everything i always wanted to remember about ffmpeg, dvdrip and transcode, but was afraid to retain.
After lot's of head banging trying to figure out which video format princess blackberry (BB) isn't allergic to, i came across this post.
This tipped me off to the fact that BB likes xvid. There are several ways to accomplish that on Linux.
Now, before i go into the details, let me point out that these settings were largely taken from the before listed post. The idea is to keep things somewhat small and to provide a working example to start out with. Actual bit rates and friends are obviously a matter of personal taste. If you have problems installing some of these packages check out https://help.ubuntu.com/community/RestrictedFormats and https://help.ubuntu.com/community/Medibuntu
On Kubuntu 8.10 (Intrepid) this meant getting ffmpeg by doing something along the lines of:
sudo apt-get install ffmpeg libavcodec-unstripped-51 libavdevice-unstripped-52 \ libavformat-unstripped-52 libavutil49 libpostproc-unstripped-51 libswscale0
Then to convert a quicktime video from my camera i would run:
ffmpeg -f mov -i p1010258.mov -vcodec libxvid -s 240x160 -qscale 10 -ab 48k -ar 22050 -ac 1 -acodec libmp3lame test.avi
This basically means in short:
- take the quicktime movie (-f mov)
- by the name (-i p1010258.mov)
- convert it to ISO MPEG4 (-vcodec libxvid)
- optionally scale it (-s 240x160)
- requantize it to reduce its size (-qscale 10)
- set the audio bitrate (-ab 48k)
- with a sample rate (-ar 22050)
- and one channel, mono (-ac 1)
- using the lame encoder (-acodec libmp3lame)
- and finally call the output (test.avi)
I think the -f mov -i p1010258.mov order makes a difference, because it failed for me the other way around.
One way to find out what format a video is, is to run tcprobe, which comes with transcode, discussed below. In our example that would be something like:
# tcprobe -i p1010258.mov [tcprobe] Apple QuickTime movie file [probe_mov.c] audio codec=raw [probe_mov.c] video codec=jpeg [tcprobe] summary for otrs/p1010258.mov, (*) = not default, 0 = not detected import frame size: -g 640x480 [720x576] (*) frame rate: -f 30.000 [25.000] frc=5 (*) audio track: -a 0  -e 8000,8,1 [48000,16,2] -n 0x1 [0x2000] (*) length: 555 frames, frame_time=33 msec, duration=0:00:18.500
tcprobe doesn't always work, in which case opening the file in a media player and looking at the clip properties might help.
sudo apt-get install dvdrip
After running DVD::Rip for the first time it greets you with a wizard to specify defaults and check dependencies. The dependency check is incredibly helpful, and i recommend getting whatever is missing. Usually adept or synaptic are pretty helpful with this. With this out of the way, here's a sample project.
- After opening DVD::Rip create a new project.
- Then rip your desired track off the DVD (In my case an easy choice, but usually the largest track).
- Adjust your image as desired.
- After picking a preview frame, i first selected "No modifications" and hit "Apply Preset Values"
- Then i entered 240 in the Zoom - Width Field followed by hitting "Calc Height"
- Adjust transcode as needed. Relevant items are:
- Container AVI
- Video Codec xvid
- 2 Pass encoding No
- Audio MP3
- Bitrate 48kbits
- I initially set the frame range for testing on a small sample.
- The transcode options -E 22050,0,1. I set -E for the third '1'(Mono) parameter, otherwise i could have used the hz field next to the bitrate above.
- Finally -o /tmp/test.mp4 or wherever the output is to be stored.
- Now for some reason, when doing only partial frames, DVD::Rip does something after it converts the fragment that takes a lot of time and is really hard to kill. So for testing i run transcode from the command line. To get the command you can either goto "Debug - Show Transcode commands" or just hit CTRL-t. Then scroll down to "Transcode Command:"
- Then run a slightly trimmed down version of that from the command line.
transcode -J normalize -Y 2,0,2,0 -L 19390 -w 2540,50 -i /tmp/dvdrip-data/sample/vob/001/ \ -y xvid -M 2 -Z 240x180 --print_status 25 --a52_drc_off -E 22050,0,1 -x vob -b 48,0,2 -a 0 \ -H 10 -o /tmp/test.mp4 -c 10-510 -f 24,1
- Test the video and repeat until the result is desirable. Then take out the frame range parameters and just hit the "Transcode" button.
This would not have been possible without the great work that many open source volunteers have put into the above listed software products. To make my point more clear, i spent a good part of a night head banging with the dysfunctional Windoze Software that came with my BB. It did not work, and was otherwise very frustrating to deal with.
So as a closing statement, i'd like to express my thank you to them.