Hi guys !
Googling aound, i found a little script on this site
http://cmisip.home.insightbb.com/Here it comes :
#!/bin/sh
#version 1.1
#Changes 1-1.1
#Added aspect ratio. There will be black bars on top and bottom to keep the resolution at 320x240 to avoid software scaling on the Z.
#Fixed AV_DELAY
#This script should convert any mplayer playable video file (audio + video) to ogm format playable on the sharp zaurus 5600 using mplayer with Tremor codec support. You need mencoder and mplayer of course, plus oggenc and ogmmerge.
#Variable assignment
ENCODE_RATE=22050
AV_DELAY=200
VIDEO_BITRATE=150
OUTPUT_FPS=15
BRIGHTNESS=15
AUDIO_QUALITY=2
X_RESOLUTION=320
Y_RESOLUTION=240
#Check the command line arguments
if [ -z "$1" ]; then
echo "Usage is 'createogm ' "
exit
fi
if [ -z "$2" ]; then
echo "Usage is 'createogm ' "
exit
fi
if [ -f "$2" ]; then
echo "The file $2 exists. Aborting "
exit
fi
#find $1 2>/dev/null
#if [ $? = 1 ]; then
# echo "Cannot find source file. Aborting"
# exit
#fi
#Check the source audio rate
AUDIO_RATE=$(mplayer -vo null -ao null -frames 0 -identify $1 2>/dev/null | grep "ID_AUDIO_RATE" | sed "s/ID_AUDIO_RATE=//g")
if [ -z $AUDIO_RATE ]; then
echo "Cannot detect audio in source file. Aborting"
exit
fi
#Delete log files from previous encodes
if [ -f divx2pass.log ]; then
rm divx2pass.log
fi
if [ -f audiotmp.wav ]; then
rm audiotmp.wav
fi
if [ -f videotmp.avi ]; then
rm videotmp.avi
fi
if [ -f audiotmp.ogg ]; then
rm audiotmp.ogg
fi
#Encode the video
#First Pass
nice -19 mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:trell:mbd=2:vqmin=2:vqmax=31:v4mv:vmax_b_frames=1:cmp=2:subcmp=2:precmp=2:predia=1:dia=1:vme=4:vqcomp=0.6:vlelim=9:vcelim=-4:idct=7:lumi_mask=0.05:dark_mask=0.01:vstrict=-1:cbp:vfdct=1:vbitrate=$VIDEO_BITRATE:keyint=150:vpass=1 -vop expand=$X_RESOLUTION:$Y_RESOLUTION,pp=hb/vb/dr,eq=$BRIGHTNESS,scale=$X_RESOLUTION:-2,hqdn3d=8:6:12:lavcdeint -ofps $OUTPUT_FPS -zoom -sws 2 -o /dev/null $1
#Second Pass
nice -19 mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:trell:mbd=2:vqmin=2:vqmax=31:v4mv:vmax_b_frames=1:vb_strategy=0:cmp=2:subcmp=2:precmp=2:predia=1:dia=1:vme=4:vqcomp=0.6:vlelim=9:vcelim=-4:idct=7:lumi_mask=0.05:dark_mask=0.01:vstrict=-1:cbp:vfdct=1:vbitrate=$VIDEO_BITRATE:keyint=150:vpass=2 -vop expand=$X_RESOLUTION:$Y_RESOLUTION,pp=hb/vb/dr,eq=$BRIGHTNESS,scale=$X_RESOLUTION:-2,hqdn3d=8:6:12:lavcdeint -ofps $OUTPUT_FPS -zoom -sws 2 -o ./videotmp.avi $1
#Extract the audio
nice -n 19 mplayer -vc dummy -vo null -ao pcm -aofile ./audiotmp.wav $1 2>/dev/null
#Convert to ogg
if [ $AUDIO_RATE -eq $ENCODE_RATE ]; then
nice -n 19 oggenc -r -C 2 -R $AUDIO_RATE -B 16 -q $AUDIO_QUALITY -o audiotmp.ogg audiotmp.wav
else
nice -n 19 oggenc -r -C 2 -R $AUDIO_RATE -B 16 -q $AUDIO_QUALITY --resample $ENCODE_RATE -o audiotmp.ogg audiotmp.wav
fi
#Multiplex the audio and video streams
nice -n 19 ogmmerge -o $2 videotmp.avi --sync $AV_DELAY audiotmp.ogg
#Delete the temporary files
rm audiotmp.ogg
rm audiotmp.wav
rm videotmp.avi
rm divx2pass.log
It works fast and very well. It produces light and beautiful movies : a 20min episode of futurama is 30mo and Metropolis (2 hours) is 190 mo. To use it, it's simple :
sh createogm
One thing is to be noticed yet : you should edit the "Y_RESOLUTION=240" line in order to keep your aspect ratio.
This leads me to a request : could someone optimize this script so that it automtically keeps the video aspect ratio or automatically crop depending on the output ? I don't know a lot about this, but i'm trying to learn , any help would ba appreciated.
PS: feel free to mail the author of this script, he did a good job !