dv 2 h.264
First, I tried to encode DV files by mplayer / mencoder / faac and x264, inspired by this article . I didn’t get much further than successfully encode audio, because with video I failed to get good video after few attempts. So I switched to ffmpeg which seems much more easier to operate, since it works on both audio and video in one command.
First, I had to compile my own x264 and ffmpeg: those that available in ubuntu repo are lacking some features. Here is excellent instruction for this.
Second, here is excellent introduction on the matter, short but enough to start do things.
And here is my little script, which I use to encode a file to h264/aac. Usually I have a bunch of files, but I prefer to code a loop by hand in console ad-hoc, calling this script within each iteration.
#!/bin/sh
#ONE (COMPULSORY) PARAMETER - input file.
#two pass encoding with ffmpeg (compiled with avc / aac support)
#optimal resolution for youtube: 640x480
FL=$1
PRE="slow"
RES="-s 600x480"
bit_B=2M
bit_BR=4M
A_BIT=128K
COMMON_ATTR="-threads 0 -y $RES"
SUFF="MP4"
FL_OUT=${FL%.*}.$SUFF
if [ ! -f "$FL" ]; then
echo "no file $FL found"
exit 1
fi
echo ""
echo "working on $FL"
echo ""
ffmpeg -i $FL -vcodec libx264 -vpre ${PRE}_firstpass -pass 1 -b $bit_B \
-bt $bit_BR -an $COMMON_ATTR -f rawvideo /dev/null
ffmpeg -i $FL -vcodec libx264 -vpre $PRE -pass 2 -b $bit_B -bt $bit_BR \
-acodec libfaac -ab $A_BIT $COMMON_ATTR $FL_OUT