A while ago I wrote the “official” video transcoding for Maemo how-to based on the wiki page and some heuristics.
The interesting thing here is the intelligent script that automatically finds the right parameters to use for the encoding.
Some of the considerations include:
- As higher framerate as possible. For smooth videos.
- Keep aspect-ratio. So the videos don’t look weird.
- No cropping. You might miss something.
- Single pass. Bigger files, but constant CPU usage.
Is this thing really smart? Let’s try it.
Crappy clip from YouTube
transcode.rb -v -i youtube.flv
* Input: 320x240 [4:3], 29.917 fps, 0 kbps.
* Output: 320x240 [4:3], 29.917 fps, 400 kbps.
mencoder youtube.flv -o youtube_it.avi -srate 44100 -oac mp3lame -lameopts vbr=0:br=128 -af volnorm -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400 -ofps 29.917000
Nothing special, the script maintained all the parameters, so there shouldn’t be any problems. Also, the aspect-ratio is not so different from the one of the device. This one is OK.
DVD
transcode.rb -v -i dvd://1
* Input: 720x480 [3:2], 29.97 fps, 7500000 kbps.
* Output: 400x240 [5:3], 29.97 fps, 400 kbps.
mencoder dvd://1 -o 1_it.avi -srate 44100 -oac mp3lame -lameopts vbr=0:br=128 -af volnorm -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=400 -ofps 29.970000 -vf-add scale=400:240
In this case the aspect-ratio is slightly modified (less than 10%), but the target aspect-ratio is exactly the same as the one of the device, so, it will look good.
So far the script does seem intelligent
High Definition
Now let’s try a non-standard resolution, high bitrate, and H.264 format.
transcode.rb -v -i starcraft.divx -f h264 -q 8
* Input: 1024x436 [256:109], 23.99 fps, 1917920 kbps.
* Output: 352x144 [22:9], 23.99 fps, 1500 kbps.
mencoder starcraft.divx -o starcraft_it.avi -srate 44100 -oac mp3lame -lameopts vbr=0:br=128 -af volnorm -ovc x264 -x264encopts bitrate=1500:nocabac -ofps 23.990000 -vf-add scale=352:144
The aspect ratio now is about 4% different, that’s good. Unfortunately the aspect-ratio is quite different from the one of the device, but that’s not too bad.
This is how it would look like:
note H.264 videos look pretty good on the device.
Conclusion
So far there hasn’t been a single video where I had to modify the parameters that this algorithm suggested; sometimes the quality is not that good but increasing it with the -q option does the trick.
Wondering if it would find the right parameter for your clips? Why don’t you try it and find out
Thanks man!
this is great. i found video encoding is the one thing people really want but have trouble to understand.
btw: it’s only a matter of personal preference, but i found that widescreen-content (not 4:3, that’s a different story) can always safely be cropped to fit the 15:9-screen of our tablets. you don’t really miss anything important and make better use of the small screen.
One small note. The device “N770″ does not exist.
It’s a very great script, I am using it to convert my videos the proper way.
Thanks for it!
This is similar to my tablet-encode script at http://mediautils.garage.maemo.org/tablet-encode.html – which gives you the option of “optimising” the aspect ratio by limited cropping and scaling – or keeping it exactly as-is.
Personally, as someone who rabidly objects to any change from the original aspect ratio on a DVD or TV broadcast, I find the optimisation usually unnoticeable – but the option’s there as YMMV.
Hi,
I just run the script from my Mac and it returns the following message:
a$ transcode -v -i Get_Smart.mov -f h264 -q 8 -d N800
Error: Bad input file: “Get_Smart.mov”
What I missing? or it is designed only for Linux?
Regards,
Taguapire.
Thanks for the comments guys, I’ll fix some stuff based on that, perhaps even add cropping even though I don’t like it
ossi1967: can you point me to one of those widescreen clips?
Andrew Flegg: the UI looks good, but I like to have more flexibility on the algorithm. That’s why I propose to split the algorithm from the application itself, the different algorithms can be used on the same application.
Not only that but the same algorithm can be used on different applications: Media Converter, Conduit, or tablet-encode.
If you don’t like any of the algorithms available you can tweak one and it could be used by many applications.
Taguapire: You need Ruby, mplayer and mencoder. I’m guessing you need to install mplayer/mencoder.
Hi,
I solved the issue with the error message, BUT… I did a try with a HD trailer downloaded from Apple Site “Get Smart” I used h264 as codec -q 8 and -q 9, it get slow in complex scenes, It didn’t played smooth in my N810
BTW: Mplayer for maemo and Media Player from Nokia (included with the N810), did not played the movie in the same aspect ratio. Nokia Player zoomed the image while Mplayer just showed the entire screen where I could see the two black bars at top/bottom. Some body knows why this happned?
Regards,
Taguapire.
Pingback: 100,000 views, and some stats « Felipe Contreras