Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Really, I've read the man pages and searched the forums...
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
mirko_3
l33t
l33t


Joined: 02 Nov 2003
Posts: 605
Location: Birreria

PostPosted: Tue Mar 09, 2004 8:26 pm    Post subject: Really, I've read the man pages and searched the forums... Reply with quote

...but couln't find an understandable solution to my simple problem:
I have a big (~1.3GB) mpeg video file, and want to reencode it to lower bitrate. I presume I have to use mencoder, but couldn't find the correct options.. any help?
thanks
_________________
Non fa male! Non fa male!
Back to top
View user's profile Send private message
bmichaelsen
Veteran
Veteran


Joined: 17 Nov 2002
Posts: 1277
Location: Hamburg, Germany

PostPosted: Tue Mar 09, 2004 8:53 pm    Post subject: Reply with quote

you could also use transcode, but you would have to use aviindex to generate a file index before encoding ...
If you are more specific about the format you want to get I will provide you a commandline ...
Back to top
View user's profile Send private message
mirko_3
l33t
l33t


Joined: 02 Nov 2003
Posts: 605
Location: Birreria

PostPosted: Tue Mar 09, 2004 8:58 pm    Post subject: Reply with quote

simply mpeg to mpeg... thanks
_________________
Non fa male! Non fa male!
Back to top
View user's profile Send private message
d_f0rce
n00b
n00b


Joined: 06 Oct 2002
Posts: 27

PostPosted: Tue Mar 09, 2004 11:14 pm    Post subject: Reply with quote

This is not as easy as you might think. The problem is without knowing the size of the audio track you can't calculate the bitrate to use to get a specific output size. And even if you know the bitrate to use it is hard to predict the output quality of your new video.

If you just want to reduce the size of your mpeg without bitrate and quality considerations you could use something like this:

mencoder -oac copy -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=BITRATE -vop scale=X:Y -o output_file.avi input_file

You have to substitute BITRATE with the new bitrate to use (e.g. 768 for 768 kbit/s), X with the new width in pixels (e.g. 720) and Y with the new height in pixels (e.g. 576).
If you don't want to scale the output video to a new size you can ommit "-vop scale=X:Y" from your command line.

This is the most simple command line to reduce the size of a video file. Keep in mind that mplayer/mencoder offers lots of features to control output quality and size. If you want to predict the output size and quality and get the most out of mencoder you have to use a multi-pass encoding.

Here is a real world example:

mencoder -ovc frameno -o frameno.avi -oac mp3lame -lameopts preset=standard input_file

This will reencode the audio track of your input_file to MP3 with standard settings (these are quite ok for everyday use) and produce an output file named frameno.avi in your current working directory.
After reencoding the audio track one can easily calculate the new bitrate to use to get a specific output size. Don't worry, mencoder does this for you. The output after this step should look something like this:

Recommended video bitrate for 650MB CD: 789
Recommended video bitrate for 700MB CD: 863
Recommended video bitrate for 800MB CD: 1010
Recommended video bitrate for 2 x 650MB CD: 1744
Recommended video bitrate for 2 x 700MB CD: 1891
Recommended video bitrate for 2 x 800MB CD: 2185

Now you know your new bitrate to use to get the output_file on one or two CDs but you can't really tell what the quality will be if you don't change the resolution. Mencoder offers some contributed tools to precalculate the output quality but this is too hard for beginners. Look for (calcbpp.pl) if you're interested. For now you should just descide which output resolution you want keeping the following in mind:

- the aspect ratio should be the same as your original size.
- the new output width and height should be divideable by 8 as this is the smallest mpeg block possible. You will get a quality loss if this is not the case!
- don't use too high resolutions if you use bad codecs like mpeg2.


At this point you can directly reencode your file with the new bitrate and size but this will not produce best quality. To really get the best quality possible mencoder has to analyze your video to know which sequences need high bitrates and which are ok with low bitrates.

This is done with:
mencoder -o /dev/null -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=863:vhq:vpass=1 -vop scale=512:288 input_file

In this example mencoder analyses an input_file which will be reencoded to a MPEG4 DIVX file using 863 kbit/s and an output resolution of 512:288 pixels.
If you want an MPEG2 output file you can of course use 'mpeg2video' again instead of 'mpeg4'. The parameter 'vhq' tells mplayer to use 'very high quality' and 'vpass=1' tells mplayer that this is the first pass of a two pass encoding. After this step you don't have your new movie yet but a .log file which tells mplayer which scene in your movie needs which bitrate.

Finally you can create your new output video using nearly the same command line as above:

mencoder -o outpu_file.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=863:vhq:vpass=2 -vop scale=512:288 input_file

Beware that you now have to use 'vpass=2' and specify a real output file with '-o filename'. You are not allowed to change the bitrate or output video size!

That's it. Now you should have your new output video. Keep in mind that mencoder offers many more features to control your output video quality. Check the mplayer homepage for detailed instructions.

Also keep in mind that it is much faster to transcode a video than to reencode it (The motion vectors are reused by a transcoder).

Greets,
Alex
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum