Mplayer

From wiki

Jump to: navigation, search

Mplayer is a good piece of software, wonderfull for manipulating video&audio, even s treams.

Contents

Dump video streams

{{{

% mplayer -dumpfile outputfile -dumpstream streamurl

}}}

Example:

{{{

% mplayer -dumpfile some_wm_file.wmv -dumpstream mms://some.stream.here

}}}

.mpeg/other -> .avi/other with mencoder

Adapted/Stolen from [http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide#Generating_AVIs_with_fixed_outpu t_size_.282-pass_encoding.29 here].

To make avi's with a fixed size look at the audio track first, multi-pass encoding is anyway better, this will

  1. Encode audio track to determine its size.
  2. Analyze video track (first-pass).
  3. Reencode video track (second-pass).

First you have to choose the audio codec you want to use. If you don't want to reencode the audio track (you w ant to keep ac3) you can use "-oac copy". In this example I use the lame mp3 encoder with standard presets whi ch are quite ok for everyday use.

{{{ mencoder -ovc frameno -o frameno.avi -oac mp3lame -lameopts preset=standard input_movie }}}

This command generates the file frameno.avi in your current working directory containing the reencoded audio t rack. Do not use another name for this file as mencoder expects to find "frameno.avi" in a later step. After e ncoding the audio track mencoder spits out a list of possible output sizes and bitrates.

{{{ 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 }}}

Personally a bitrate of 750+ is ok for TV use.

Knowing bitrate you can now directly reencode your video. But this will not produce optimum quality. To get th e best quality possible mencoder first has to analyze your input video track to determine which sequences need

high bitrates and which are ok with low bitrates. If you _DO_KNOW_ what you want to scale as add "-vop scale=

512:288" or similair syntax before the 'input_movie' argument. Since we're doing a straight conversion to save

some time/bandwidth we'll ignore this.

{{{ mencoder -o /dev/null -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=863:vhq:vpass=1 input_movie

}}}

In this example mencoder analyses an input_movie which will be reencoded to a MPEG4 DIVX file using 863 kbit/s . Of course you can use your favorite output codec instead of DIVX. The parameter 'vhq' tells lavc to use 'ver y high quality'. 'vpass=1' tells it that this is the first pass of a two pass encoding. After this step you do n't have your new movie yet but a .log file which is needed to reencode your movie in best quality.

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

{{{ mencoder -o output_file.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=863:vhq:vpass=2 input_movie }}}

Beware that you now have to use 'vpass=2' and specify a real output file with '-o filename'. You are not allow ed to change the bitrate or output video resolution any more! This step uses your 'frameno.avi' file from the first step and the logfile from the second to generate the final video output_file.avi. You can then delete th e logfile and 'frameno.avi'. If you want to do the saale thing remember to add the "-vop scale=512:288" or similair command to the argument s above.

HDTV formats to something playable on the XBOX, etc.

Since 1920x1080, etc. resolutions require toomuch CPU we need to downscale these 6gb monsters..

Convert 1920x1080 to 960x540, playable by Xbox (700mhz CPU) but still rather big...(try #1):

{{{ movie=bleat.ts ; donefile=OUTPUT.avi ; mencoder "$movie" -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg4:vqscale =3:vhq:v4mv:autoaspect:trell -vf field=0,scale=960:540 -o "$donefile" }}}


Adding some preset mp3lame option as well as scaling the resolution down makes 6gb/40min files to arond 700mb,

much better, trying this out now - scared of audiosync:

{{{ movie=dvcam.ts ; donefile=OUTPUT.avi ; mencoder "$movie" -oac mp3lame -lameopts preset=standard -ovc lavc -lav copts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell:vbitrate=863 -vf field=0,scale=624:352 -o "$donefile" }}}

Audiosync definitely not correct with above example lets try:

Try #3: Trying seperate audio encoding process + 2 pass (not 3) encoding, takes much longer but lets see:

{{{ movie=dvcam.ts ; donefile=OUTPUT.avi ; rm divx2pass.log frameno.avi $donefile ; mencoder -ovc frameno -o frame no.avi -oac mp3lame -lameopts preset=standard $movie ; mencoder -o /dev/null -oac copy -ovc lavc -lavcopts vco dec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell:vbitrate=863:vpass=1 -vf field=0,scale=624:352 $movie ; mencoder

-o $donefile -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell:vbitrate=863:vpas

s=2 -vf field=0,scale=624:352 $movie }}}


Still badly out of sync, I read about frame dups being the problem [http://axljab.homelinux.org/Mencoder_DVD_t o_OGM here].

Try #4 harddup:

{{{ movie=dvcam.ts ; donefile=OUTPUT.avi ; rm divx2pass.log frameno.avi $donefile ; mencoder -ovc frameno -o frame no.avi -oac mp3lame -lameopts preset=standard -vf field=0,scale=624:352,harddup $movie ; mencoder -o /dev/null

-oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell:vbitrate=863:vpass=1 -vf field

=0,scale=624:352,harddup $movie ; mencoder -o $donefile -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:v hq:v4mv:autoaspect:trell:vbitrate=863:vpass=2 -vf field=0,scale=624:352,harddup $movie }}}

Harddup no joy, lets just copy the audio stream:

Try #5 Big wav copy:

{{{ movie=dvcam.ts ; donefile=OUTPUT.avi ; rm divx2pass.log frameno.avi $donefile ; mencoder -ovc frameno -o frame no.avi -oac copy vf field=0,scale=624:352,harddup $movie ; mencoder -o /dev/null -oac copy -ovc lavc -lavcopts

vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell:vbitrate=863:vpass=1 -vf field=0,scale=624:352,harddup $movi

e ; mencoder -o $donefile -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:autoaspect:trell:vbitr ate=863:vpass=2 -vf field=0,scale=624:352,harddup $movie }}}

No, that just results in same audiosync-outness.

Try #6, lets take our first 1.5gb resulted file step and just scale the resolution down again, see what it doe s:

{{{ I=input.ts ; O=OUTPUT.avi ; mencoder "$I" -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vhq:v4mv:aut oaspect:trell -vf field=0,scale=624:352 -o "$O" }}}

The above seems to work... why?! Results in ~700mb file (assuming ~6.5gb/42mins)!


Interesting thus far: this


Converting Divx/VidX/avi to DVD format for playing on propper DVD players

Need to figure out how to author propper DVD's to play on propper set-top players, this is going to be fun.

So far, interesting stuff:

Mencoder stuff

DVD Author software for linux

Some other stuff