quarta-feira, 14 de maio de 2008

How to FAST convert your videos to iPod MP4 on Ubuntu


I ran a lot of experiments and finally I wrote a VERY FAST script to convert videos to my iPod Nano 3rd Generation. It encode videos to XviD with ffmpeg and utilizes AAC as audio codec. The final quality is good, the result video file is small and the conversion time is short. So, what else could you want???



You can install it by coping and pasting the following lines into your terminal:
Copyright © 2008 Everthon Valadão
sudo wget http://homepages.dcc.ufmg.br/~evaladao/storage/scripts/ipodencoder.sh -O /usr/local/bin/ipodencoder sudo chmod +x /usr/local/bin/ipodencoder

And to encode a video file, just type:

ipodencoder input_video.avi

OBS.: If your ffmpeg do not have XviD/AAC support, you can compile it from source with some additional parameters to get support to xvid, aac, h264, theora, etc... If you are using Ubuntu, just type in the command line:

sudo su cd /tmp apt-get build-dep ffmpeg apt-get install libvorbis-dev libogg-dev libtheora-dev liba52-*-dev libdc1394-*-dev libgsm1-dev liblame-dev libfaad2-dev libfaac-dev libmp4v2-dev libx264-dev libxvidcore4-dev apt-get source ffmpeg cd ffmpeg-*/ ./configure --enable-gpl --enable-pp --enable-pthreads --enable-libvorbis --enable-libogg --enable-libtheora --enable-liba52 --enable-dc1394 --enable-libgsm --disable-debug --enable-libmp3lame --enable-libfaad --enable-libfaac --enable-xvid --enable-x264 make make install

Um comentário:

Everthon Valadão disse...

gtblackwell says: Nice program! One question: Is there a way to correct for widescreen videos? I suppose a workaround with mencoder is possible, but that pretty much cancels out the speed that your solution provides.

everthonvs reply: Actually I use ffmpeg to encode the MP4 videos (I did some extensive tests with ffmpeg X mencoder and ffmpeg get the best speed/quality performance). Answering your question, "for widescreen videos, use 320x192. And if you want to transcode for TV output, you should use these resolutions: widescreen 480x288 and fullscreen 480x360". So, to change my original script to widescreen encoding, just type

sudo sed -i 's/WH="320x240"/WH="320x192"/g' /usr/local/bin/ipodencoder

And don't worry, because it do not cause significant performance issues!

[]'s

P.S.: if you wanna take a look at the code and change manually the resolution, type

sudo gedit /usr/local/bin/ipodencoder

and change the line
WH="320x240"
to
WH="320x192"
or whatever resolution you want to.