Converting video for the Nexus One using Ubuntu's Ffmpeg

I've been playing around with various software and settings for transcoding video for the Nexus One. The bright, clear 800x480 screen of the Nexus One makes it great for watching videos. In order to have the smallest possible file size and to take advantage of the decoding hardware the video needs to be encoded using the H.264 codec.

On your Ubuntu machine that will be doing the transcoding (converting from one video type to another) you will need to install ffmpeg with the X.264 libraries. As this is a licenced codec (ie. unfree) you will need to add the Medibuntu repositories. Open up a terminal and enter:

 

sudo wget http://www.medibuntu.org/sources.list.d/`lsb_release -cs`.list --output-document=/etc/apt/sources.list.d/medibuntu.list && sudo apt-get -q update && sudo apt-get --yes -q --allow-unauthenticated install medibuntu-keyring && sudo apt-get -q update

 

Then enter the command to install ffmpeg and the extra codecs:

 

sudo apt-get install ffmpeg libavcodec-extra-52

 

If you want more information or are having trouble with these last steps, check out this thread on the Ubuntu forums.

Once this is done you will need to tell ffmpeg about the presets that X.264 expects by copying them from the ffmpeg presets to a new hidden folder we'll make:

 

mkdir ~/.ffmpeg
cp /usr/share/ffmpeg/*.ffpreset ~/.ffmpeg

 

The presets that currently ship with ffmpeg don't include a specific one for the Nexus One so we will make copy one the presets and make the necessary change:

 

cp ~/.ffmpeg/libx264-normal.ffpreset ~/.ffmpeg/libx264-nexus1.ffpreset

 

Then open up the file ~/ffmpeg/libx264-nexus1.ffpreset in your favourite editor and change the first line from "coder=1" to "coder=0".

Finally you are ready to take an exsiting video and convert it for your Nexus One:

 

ffmpeg -i inputfile.xyz -s 800x480 -vcodec libx264 -vpre nexus1 -b 320000 -acodec libfaac -ac 2 -ar 48000 -ab 32000 -aspect 16:9 outputfile.N1.mp4

 

This setting works extremely well for animation (eg. anime) however may not work well to optimize your video for live action, full colour video. To get those to play you may need to increase the bitrate to 480000 and decrease the size to 400x240. Thus your command would be:

 

ffmpeg -i inputfile.xyz -s 400x240 -vcodec libx264 -vpre nexus1 -b 480000 -acodec libfaac -ac 2 -ar 48000 -ab 32000 -aspect 16:9 outputfile.N1.mp4

 

For live-action with hifi sound and maximum quality use these settings. Feel free to push the bitrate even higher which will give you larger file sizes but a higher framerate:

 

ffmpeg -i inputfile.xyz -s 800x480 -vcodec libx264 -vpre nexus1 -b 720000 -acodec libfaac -ac 2 -ar 44000 -ab 128000 -aspect 16:9 outputfile.N1.mp4

 

After churning away for some time (depending on the speed of your computer) you should have a shiny new H.264-encoded video file which will play nicely on your Nexus One.

If you are only getting a black screen with the sound and your source has an unusual aspect ratio, try dropping the forced 16:9 requirement by leaving out "-aspect 16:9".

 

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.