Posts Tagged ‘ffmpeg’

Converting movies for sony ericsson with ffmpeg

June 3rd, 2009 Comments off

I know there is already a lot of similar blogs and tutorials available on the net about converting movies for mobile devices, but as already some peoeple have discovered writing a blog is to keep log of our experiences and have easy way back to our experiences.

So I got new sony ericsson cell phone “w890i” the first criteria to chose it was its thin casing, but I got in the suite playback of movies.

First step was to find out format of the movie handled by the phone, I have grabbed one of example movies to my disk and used ffmpeg to see its format:

ffmpeg -i example.mp4 /dev/shm

And the most important lines of the output are:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'example.mp4':
Stream #0.0(und): Video: h263 ...
Stream #0.1(und): Audio: aac...

So in the line “Input” we see list of container formats – extensions we can use for our file, in next lines we see Stream for video and its codec “h263” and audio codec “aac”, we will use this values for converting movies for the phone.

My first problem was to merge movie from few parts, I have tried to use avidemux, but without sucess, next one was mencoder, after few tries I have found good combination for my movies:

mencoder -ofps 24 -ovc copy -oac mp3lame input*.wmv -o movie.avi

I have used “-ofps” switch to eliminate duplikate frames, “-ovc copy” is to copy the video stream, for the audio codec “-oac” I was forced to use mp3lame, it was not working with standard “copy”. There is a lot of combination, but mostly important are those one that I have used, consult manual page of mencoder to get them all.

After getting all parts into one file I could finally use ffmpeg to convert the movie for the phone:

ffmpeg -i movie.avi -s qcif -vcodec h263 -acodec libfaac movie.3gp

Ffmpeg will autodetect input format and use given params to build output, like you can see above I have added lib to aac, this should work for other codecs if the short name is not working.

Finally after few minutes of conversion I got 80 minutes movie that I could watch on my phone, most funny was that I was watching movie in low res while still working on my laptop – I could use laptop to play it with a lot better resolution … but how else I could check that conversions went fine.

The last hint is to load phone batery watchin 80 minutes of movie can eat 30 upto 50% of it.

Categories: Linux Tags: , ,