I recently purchased a Vidego28 handheld MP4 player with a 2.8” display – which is actually a rebranded ONDA VX858 – and discovered that it has very specific requirements for the videos it plays.
The manufacturer provides a Windows binary-only utility for converting your videos to something the Vidego28 can read, but because I don’t use Windows, and because I prefer using the command line for automating these sorts of tasks, I immediately set out to discover exactly what format my videos should adhere to.
Googling around, I found that the videos it plays should be 12bpp XviD encoded AVIs at or below 24 fps (frames per second) with a maximum bitrate (for the video) of 800kbit/s and a resolution of 320×240 (which is the size of the display, in pixels.) I also found that the audio portion of the AVI should be encoded in the MP2 format. Using mencoder (http://en.wikipedia.org/wiki/MEncoder), I cobbled together the following command to do the job, partly from experiment and partly from what I had found in someone else’s blog (all on one line):
mencoder -mc 0 -noodml inputfile.avi -of avi -o outputfile.avi -ofps 24 -vf-add scale=320:240 -vf-add expand=320:240:-1:-1:1 -srate 44100 -ovc xvid -xvidencopts bitrate=400:max_bframes=0:quant_type=h263 -oac twolame -twolameopts br=160
At this point, I had partial success. I was able to take my videos and convert them to a format the Vidego28 could read. The problem was that almost immediately during playback on either my computer or the MP4 player, the audio and video became so out of sync that it was impossible to make use of the files mencoder produced. I spent hours on Google looking for a solution and tweaking the above command, without success.
At some point during my experimenting, I discovered that ffmpeg (http://ffmpeg.mplayerhq.hu/) could produce AVI files as well, and decided to give it a shot. Unfortunately, the files it produced were not in a format the Vidego28 could read, but out of curiosity, I decided to see what would happen if I used mencoder to take the output of ffmpeg and re-encode it per the original command I had tried earlier, since the files ffmpeg produced were in sync when played back on my laptop. To my astonishment, for whatever reason, mencoder was able to output an AVI in which the audio and video remained at all times in sync when played on the Vidego28!
Finally, I decided to write a simple script so that I could automate the process of calling ffmpeg, followed by mencoder, the result of which is listed below:
FPS=$1 INPUT=$2 OUTPUT=$3 # Make sure all the required arguments were passed if [ -z $FPS ] || [ -z $INPUT ] || [ -z $OUTPUT ]; then echo echo "Usage: $0 [fps] [input file] [output file]" echo exit 1 fi # Make sure $FPS is valid if [ $FPS -lt 1 ] || [ $FPS -gt 24 ]; then echo echo "error: frames per second should be between 1 and 24" echo exit 1 fi # Let's do our stuff! ffmpeg -i $INPUT -r $FPS /tmp/$OUTPUT mencoder -mc 0 -noodml /tmp/$OUTPUT -of avi -o $OUTPUT -ofps $FPS -vf-add \ scale=320:240 -vf-add expand=320:240:-1:-1:1 -srate 44100 -ovc xvid \ -xvidencopts bitrate=400:max_bframes=0:quant_type=h263 -oac twolame \ -twolameopts br=160 rm /tmp/$OUTPUT
The above script takes as parameters the desired FPS (which should be between 1 and 24), the source file (which can be any format that mencoder supports) and the destination (the file that will go on your MP4 device). A sample call would look like this:
vidego.bash 24 input.file output.avi
Just copy output.avi to your Vidego28 (or ONDA VX858), and you’ll be good to go!
admin April 28th, 2008
Posted In: Uncategorized