PGTS Humble Blog
Thread: Tips/Tricks For Programming etc
|You underestimate the power of the Dark Side!|
Convert Video For A5146 With ffmpeg
Chronogical Blog Entries:
Date: Sun, 27 Dec 2009 15:03:28 +1100
Recently I purchased a Dick Smith A5146 MP3 player for one of our kids. Like so many of the things that went into the Christmas stocking, there were a few technical problems when it came out. The problem we had was persuading the MP3 player to play videos.
The A5146 MP3 represents excellent value for money. The features this little package offers are:
- 8 GB (flash) memory.
- Touchlight keys with back-light (resembling the iPod).
- 2 inch TFT LCD colour display.
- Supports a wide range of audio codecs (including OGG!)
- Supports video (only AVI)
- Built-in FM radio
- USB 2.0 - standard File connection.
All of it for a very reasonable price.
The decision to only support AVI was unfortunate, but understandable, given the widespread use of this proprietary encoding. With all those other great features however, it seemed a good choice.
Of course these days, kids get their videos from youtube. But I figured that it would be easy enough to change them to AVI format.
Also there is a disk included with a conversion utility. The conversion process uses a combination of Freeware and Open source Software. The package contains Firefox 3.5.1 and Winamp 5.56. And it Only works on Windows 2000/XP/Vista. Not much use if you don't own a Windows computer. The instruction manual does mention that there are lots of free and open source software to do the conversion but it doesn't include instructions on how to do it. Not that I would contemplate installing Microsoftware just to be able to convert video files. And in any case it seems that it would not cope with the youtube format.
Fortunately the manual did include this one brief but valuable sentence:
Your player supports XviD-encoded AVI files with the following specifications:
* 220 x 176 resolution at 30 frames per second (fps).
Which probably means that ffmpeg will do the job nicely, provided it has the appropriate codecs. If you haven't already got it you need to install ffmpeg. While you are about it you should get all the stuff from the ugly and bad sets. If you don't run Linux, this will probably work on a Mac (I haven't tested it yet).
Here is how I converted youtube videos (.flv) to a format that can be played by the Dick Smith A5146 MP3 player ...
Presuming you already have ffmpeg, you need to get the XviD codecs. I installed all of the following. Most of these packages were suggested by the APT program when I started investigating this:
sudo apt-get install libavcodec-unstripped-51 sudo apt-get install avifile-divx-plugin avifile-mad-plugin avifile-mjpeg-plugin avifile-player avifile-utils avifile-vorbis-plugin avifile-win32-plugin avifile-xvid-plugin
I am not entirely sure what the unstripped package does, but it seems to make it easier to convert to a container name without explicitly specifying all those tricky ffmpeg codec names.
Now, if you have all the necessary libraries, it should be possible to convert files with this command:
ffmpeg -i infile.flv -vcodec libxvid -r 30 -s 220x176 outfile.avi
However with some of the files that are not 220x176, you may get better results by trimming the picture. However if you go down this path you will have to read the man pages for ffmpeg.
In my case I wrote a script which does the conversion. You could write a script which looks in a certain folder and does the conversion. Or you could call a script which writes the files to an appropriate folder after it has been mounted.
Update: Converting to MP4 for PSP and DSi. Upgrading to 10.04
Since posting this, I have adapted the scripts to translate Youtube .FLV files to MP4 for PSP and Nintendo DSi consoles.
Basically the conversion process uses a similar command. However, you should specify an MP4 file as the output:
ffmpeg -i infile.flv outfile.mp4
You may require additional options to adjust the picture dimensions.
However, later I upgraded my desktop to Kubuntu 10.04. After the upgrade I discovered that all the conversion scripts I had written no longer worked. There was a warning message:
Seems stream 0 codec frame rate differs from container frame rate:
The real problem however was the message that appeared at the end:
Unsupported codec for output stream #0.0
10.04 had disabled the Mediubuntu repository. For more details about Mediubuntu and how to re-enable it visit the Mediubuntu Site.
Also, the libavcodec-unstripped-51 package is no longer available. Instead I found libpostproc-unstripped-51, which seems to be a replacement.