Friday, July 9, 2010

Linux FLV to 3GP Conversion

A short how-to post for Android owners who want to run Adobe Flash video they've saved on their Linux system.

The music player on the Samsung Moment handles WMA, AAC, MP3, WAV, MIDI, and OGG format music files. The video player will handle MPEG4, H.264, and XVID formats. A fairly wide range of choices that have all worked right out of the box. The YouTube application works well for streaming video but doesn't have an option to open archived .flv Flash video. They need to be converted to 3GP to be played in the Gallery app.

The tool of choice to convert flv to 3gp is ffmpeg, however Ubuntu ships a version without the required libfaac codec due to licensing differences. To add the support, install the following packages from the packages.mediabuntu.org/non-free repository:
  • libav*-extra-52
  • libav*-unstripped-52
  • libamrnb3
  • libamrwb3
  • libavutil-extra-49 (will be added automatically as a dependency)
Once those packages are installed, the following command will produce a video that can be played on the phone:

ffmpeg -i input.flv -s qcif -vcodec h263 -acodec libfaac output.3gp

Valid frame sizes (-s) at 4:3 are 128x96, 176x144, 352x288, 704x576, and 1408x1152. The qcif value is an alias for 176x144, more are listed in the video options linked below. You may want to experiment depending on the ratio of the original source.

Some useful resources if this doesn't work just right for you:
Like a lot of things, not too difficult in the final analysis. Just took a little time to find the right pieces and assemble them. Hopefully this will save someone some of that time.

Enjoy.