Sunday, May 06, 2007

converting youtube.com flv videos to mobile 3gp format

This took one full Sunday afternoon as well as evening. I would like to blog the required information before it fades away from my memory ;o)

I was watching some Simpson's videos on youtube.com and though of playing them on my mobile handset. Now flash seems to rule the roost when it comes to online videos. Almost all online video websites I know use the .flv format. so we can break our problem in two parts

  • A) get the video file from provider site
  • B) convert the flv video file to 3GP format (H263) that can play on a mobile hand set

For (A) and (B) there are many sites that allow you to download youtube videos. You just copy+paste the youtube.com URL in a box and then you can download the flv file to your hard disk. A quick google would reveal many links . To start your research you can look at the first link at the end of this post. Issue is, most of the ready made tools are geared towards dealing with individual files, forcing you to work in dumb user mode and asking for 30$ every now and then.

I wanted a script or program that I can use in batch mode or call from within my other programs. Right now I am using this perl script that is a rip-off of python youtube-dl script . I will write a java version of this script when i get some time. Downloading youtube.com videos is a non-issue but converting flv videos to 3GP format proved quite a task.

First up there is a nokia multimedia converter on windows that may work for you. Just search forums.nokia.com for more info. There are many programs that let you do the flv to other media format conversions. Just check the first link i have provided. You can look for total video converter or simple or some other tool.

Like I said, My requirements are a bit different. I want a program or script that I can call from command line to do batch processing of flv files. This proved a bit difficult because the information is scattered all over the place. There are many web pages that deal with this topic. I will post them all at the end of this post. To cut a long story short, I zeroed on ffmpeg. ffmpeg could do the required conversion if iyou build it with right switches. Now that looked like a lot of work to do but here I got lucky ;o)

Riva FLV encoder is built on top of ffmpeg and on my windows xp box I can see ffmpeg.exe inside Riva FLV encoder folders. superb! A quick check revealed that it has built-in support for 3gp and flv. (do with $ffmpeg -formats )

So this is what I use now ( Beware, I do not know much about what all options are allowed , i have to digg that bit)


C:\sw\Riva\Riva FLV Encoder 2.0>ffmpeg -i Z3Kvn28HvJw.flv -ab 8 -ar 8000 -b 200
-s 176x144 Z3Kvn28HvJw.3gp

Next up I have to see if there are any nice java wrappers around ffmpeg. And here are the links i found useful,

  1. start here with a post about youtube.com grabbers , viewers and converters
  2. Perl script to download youtube flv video
  3. And that is a rip-off of this python yuotube-dl script.(original)
  4. Nokia Multimedia converter
  5. see this post about ffmpeg 3gp display size options
  6. niemueller.de post about converting to 3gp
  7. Ubuntu + ffmpeg
  8. How to enable AMR support in ffmpeg
  9. post praising vixy.net
  10. Linuxondesktop blog detailing flv23gp conversion with mencoder and ffmpeg
  11. Home of great ffmpeg library
  12. Mplayer Home - http://www.mplayerhq.hu/
  13. Riva FLV encoder
  14. Digg.com article on how to download youtube videos
  15. How to compile ffmpeg under windows - sonke rohde (creator of Riva )
© Life of a third world developer
Maira Gall