Mplayer

From Initq

Jump to: navigation, search

Contents

Introduction

MPlayer is a movie player which runs on many systems. It plays most MPEG/VOB, AVI, Ogg/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, RealMedia, Matroska, NUT, NuppelVideo, FLI, YUV4MPEG, FILM, RoQ, PVA files, supported by many native, XAnim, and Win32 DLL codecs. You can watch VideoCD, SVCD, DVD, 3ivx, DivX 3/4/5, WMV and even H.264 movies.

Another great feature of MPlayer is the wide range of supported output drivers. It works with X11, Xv, DGA, OpenGL, SVGAlib, fbdev, AAlib, DirectFB, but you can use GGI, SDL (and this way all their drivers), VESA (on every VESA compatible card, even without X11!) and some low level card-specific drivers (for Matrox, 3Dfx and ATI), too! Most of them support software or hardware scaling, so you can enjoy movies in fullscreen. MPlayer supports displaying through some hardware MPEG decoder boards, such as the Siemens DVB, DXR2 and DXR3/Hollywood+.

MPlayer has an onscreen display (OSD) for status information, nice big antialiased shaded subtitles and visual feedback for keyboard controls. European/ISO 8859-1,2 (Hungarian, English, Czech, etc), Cyrillic and Korean fonts are supported along with 12 subtitle formats (MicroDVD, SubRip, OGM, SubViewer, Sami, VPlayer, RT, SSA, AQTitle, JACOsub, PJS and our own: MPsub). DVD subtitles (SPU streams, VOBsub and Closed Captions) are supported as well.

Info

It is always best to compile mplayer and we always do that on linux machines. On the download page the mplayer site now has downloads for windows.

Download

http://www.mplayerhq.hu

Debian downloads

Please check http://debian-multimedia.org for debian apt-get source.

Playing DVD's

D:\mplayer dvd://1 −dvd-device G:\ -slang en -alang en
$ mplayer dvd://1 −dvd-device /dev/cdrom -slang en -alang en

Looping

Use the -loop flag to loop songs like beats or samples. the number indicates the number of loops, Zero means forever. If you don't want any gaps then put the -loop flag at the end.

mplayer disco.mp3 -loop 0

Encoding

This section will tell you the easiest and simplest way to do a quick and easy rip from dvd to xvid.

Find out which part and language you want

mplayer -alang en dvd://1 -dvd-device /mnt/cdrom

Keep changing the <1> to a higher number until you get to the desired movie.

Make the right crop

mplayer -ss 60 -vf cropdetect dvd://1 -dvd-device /mnt/cdrom

Find the part in parentheses, that will be your crop dimensions. example (720:432:0:72).

Encoder

$ mencoder -alang en dvd://1 -dvd-device /mnt/cdrom -ovc xvid -xvidencopts pass=1 
-oac mp3lame -vf crop=720:432:0:72 -o movie.avi
$ mencoder -alang en dvd://1 -dvd-device /mnt/cdrom -ovc xvid -xvidencopts pass=2:bitrate=-700000 
-oac mp3lame -vf crop=720:432:0:72 -o movie.avi

This will do 24 frames and 6 core. Also the volume is turned up on the mp3 rip.

$ mencoder -alang en dvd://1 -dvd-device /mnt/cdrom -ovc xvid -xvidencopts pass=1:threads=6 
-oac mp3lame -lameopts br=128:vol=10 -vf crop=720:432:0:72 -ofps 24 -o movie.avi
$ mencoder -alang en dvd://1 -dvd-device /mnt/cdrom -ovc xvid -xvidencopts pass=2:bitrate=-700000:threads=6
-oac mp3lame -lameopts br=128:vol=10 -vf crop=720:432:0:72 -ofps 24 -o movie.avi

With -700000, mencoder will calculate the bitrate for you that comes very close to 700 meg.

I saw a problem with mencoder when subtitles are turned on, the picture would flicker. To get rid of this just turn off subtitles.

$ mencoder -alang en dvd://1 -dvd-device /mnt/cdrom -nosub -ovc xvid -xvidencopts pass=1:threads=6 
-oac mp3lame -lameopts br=128:vol=10 -vf crop=720:432:0:72 -ofps 24 -o movie.avi
$ mencoder -alang en dvd://1 -dvd-device /mnt/cdrom -nosub -ovc xvid -xvidencopts pass=2:bitrate=-700000:threads=6
-oac mp3lame -lameopts br=128:vol=10 -vf crop=720:432:0:72 -ofps 24 -o movie.avi

Duplicate Frames

To get rid of duplicate frames use:

$ mencoder -alang en dvd://1 -dvd-device /mnt/cdrom -ovc xvid -mc 0 -xvidencopts pass=1 
-oac mp3lame -vf crop=720:352:0:62,harddup -ofps 24 -o movie.avi

It should be -ofps 30 or 24. Play the movie with mplayer and see what the frame rate is, then use a lower number, normally it should be 24.

Mutiple Core processors

Use option -ovc xvid -xvidencopts bitrate=900:threads=2 for threads=2

Convert wmv to avi

$ mencoder infile.wmv -ofps 23.976 -ovc lavc -oac copy -o outfile.avi

Convert ts to avi

$ mencoder -alang en movies.ts -ovc xvid -xvidencopts pass=1 
-oac mp3lame -vf crop=720:432:0:72 -o movie.avi
$ mencoder -alang en movie.ts -ovc xvid -xvidencopts pass=2:bitrate=-700000 
-oac mp3lame -vf crop=720:432:0:72 -o movie.avi

Convert VOB to avi

$ mencoder VTS_01_1.VOB -ss 162.0 -endpos 371.0 -ovc copy -oac pcm -o /tmp/ahmed.avi
$ mencoder VTS_01_1.VOB -ss 162.0 -endpos 371.0 -ovc copy -oac copy -o /tmp/ahmed.avi

Convert avi to flv

$ mencoder -forceidx -of lavf -oac mp3lame -lameopts abr:br=56 -srate 22050 -ovc lavc -lavcopts vcodec=flv:vbitrate=250:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -vf scale=360:240 -o my.flv my.avi

Convert avi to mov

$ ffmpeg -i ahmed.avi -target ntsc-dvd -s 1280x720 ahmed.mov

Movie fits on CD

You can set the filesize you want in KiloBytes in order to make mencoder calculate the bitrate for you. This can be done by setting a "negative" bitrate, bitrate=-700000 will give you a movie file which fits nicely on a CD.

mencoder <filename.avi> -ovc xvid -oac mp3lame -xvidencopts bitrate=-700000 -o <output.avi>

Subtitles

Matroska file format detected.
VIDEO:  [avc1]  864x480  24bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
SUB: Could not determine file format
Cannot load subtitles: file.ass

The remedy: 1. Convert the ASS file to UTF-8 (or whatever encoding you are comfortable with). I used iconv:

  • iconv -f utf16 -t utf8 < file.ass > result.ass

2.Play it by using the "-utf8" switch of mplayer: mplayer -sub file.ass -utf8 file.avi. If the ASS contains special characters (such as CJK chars), use a good font by "-font /usr/share/font/cjk.ttf"

DVD Ripping

mencoder dvd://1 -ofps 23.976 -ovc lavc -lavcopts vcodec=mpeg4:v4mv:mbd=2:trell:vbitrate=900:vpass=1:turbo=1 
-oac copy -o /dev/null
  • mencoder dvd://1 This tells mencoder to play track 1 of the dvd
  • -ofps 23.976 This is specifing the typical NTSC DVD framerate. Read sections 8.2.x for more details on NTSC, interlaced and telecine
  • -ovc lavc This is saying we are going to use the libavcodec family as our "output video codec, ovc"
  • -lavcopts vcodec=mpeg4:v4mv:mbd=2:trell This is telling mencoder, that the libavcodec options are, use mpeg4 (aka Divx5) as our encoding codec, use the 4 motion vectors (per macroblock) option, use the highest setting of the Macroblock decision algorithm (mbd), also use Trellis quantization during the encoding process.
  •  :vbitrate=900:vpass=1:turbo=1 This means our bit rate is 900, this is the first video pass, and "turbo" is enabled, turbo only works on the first pass, rather when used with vpass=1
  • -oac copy -o /dev/null This tell mencoder that the output audio codec (oac) is an exact copy of the audio stream, -o = output file name, and outputting to /dev/null is the "bit bucket" nothingness.
Second pass
mencoder dvd://1 -ofps 23.976 -ovc lavc -lavcopts vcodec=mpeg4:v4mv:mbd=2:trell:vbitrate=900:vpass=2 
-oac mp3lame -lameopts vbr=3 -o Something-About-Mary.avi
  • Almost everything is the same
  • vpass=2 this time as it's the second pass
  • -oac mp3lame -lameopts vbr=3 The output audio codec is mp3lame, it's options are variable bitrate equals 3 (bitrate is 128 with this setting)
  • -o Something-About-Mary.avi is the output file name

Interlaced DVD's, Tv Series, Catoons and other Animation

mencoder dvd://1 -vf pp=md -ovc lavc -lavcopts vcodec=mpeg4:v4mv:mbd=2:trell:vbitrate=900:vpass=1:turbo=1 
-oac mp3lame -lameopts vbr=3 -o Invader-Zim.avi
  • -vf pp=md video filter is pp=md (post-processing median deinterlacer)
  • -oac mp3lame -lameopts vbr=3 -o Invader-Zim.avi With this cartoon series, the deinterlacing filter does a fine job of creating a good quality rip on the first pass. Most cartoons tend to have solid colors, more stationary objects/backgrounds etc... that make it less difficult for mencoder to process the data. The first pass doesn't have to go to /dev/null, you can overwrite the file by using the same name on the next pass, or renaming the output file, and then maybe compare a first pass to a second/third pass.

Rescaling movies

mencoder input.mpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell \
-vf scale=640:480 -o output.avi

Join Movies

mencoder -oac copy -ovc copy -idx -o output.avi video1.avi video2.avi video3.avi

Extra Help

Shortcuts

Keyboard control

<- and -> Seek backward/forward 10 seconds.

up and down Seek forward/backward 1 minute.

pgup and pgdown Seek forward/backward 10 minutes.

[ and ] Decrease/increase current playback speed by 10%.

{ and } Halve/double current playback speed.

backspace Reset playback speed to normal.

< and > Go backward/forward in the playlist.

ENTER Go forward in the playlist, even over the end.

HOME and END next/previous playtree entry in the parent list

INS and DEL (ASX playlist only) next/previous alternative source.

p / SPACE Pause (pressing again unpauses).

. Step forward. Pressing once will pause movie, every consecutive press will play one frame and then go into pause mode again (any other key unpauses).

q / ESC Stop playing and quit.

+ and - Adjust audio delay by +/- 0.1 seconds.

  • / and * Decrease/increase volume.
  • 9 and 0 Decrease/increase volume.

( and ) Adjust audio balance in favor of left/right channel.

m Mute sound.

  • _ (MPEG-TS and libavformat only) Cycle through the available video tracks.
  • # (DVD, MPEG, Matroska, AVI and libavformat only) Cycle through the available audio tracks.
  • TAB (MPEG-TS only) Cycle through the available programs.
  • f Toggle fullscreen (also see -fs).

T Toggle stay-on-top (also see -ontop).

w and e Decrease/increase pan-and-scan range.

o Toggle OSD states: none / seek / seek + timer / seek + timer + total time.

d Toggle frame dropping states: none / skip display / skip decoding (see -framedrop and -hardframedrop).

  • v Toggle subtitle visibility.
  • j Cycle through the available subtitles.

y and g Step forward/backward in the subtitle list.

F Toggle displaying forced subtitles .

a Toggle subtitle alignment: top / middle / bottom.

x and z Adjust subtitle delay by +/- 0.1 seconds.

r and t Move subtitles up/down.

i (-edlout mode only) Set start or end of an EDL skip and write it out to the given file.

s (-vf screenshot only) Take a screenshot.

S (-vf screenshot only) Start/stop taking screenshots.

I Show filename on the OSD.

! and @ Seek to the beginning of the previous/next chapter.

D (-vo xvmc, -vf yadif, -vf kerndeint only) Activate/deactivate deinterlacer.

Hardware accelerated video output

1 and 2 Adjust contrast.

3 and 4 Adjust brightness.

5 and 6 Adjust hue.

7 and 8 Adjust saturation.

SDL Video Output Driver

c Cycle through available fullscreen modes.

n Restore original mode.

Multimedia Keyboard

PAUSE Pause.

STOP Stop playing and quit.

PREVIOUS and NEXT Seek backward/forward 1 minute.

GUI Support (if compiled in)

ENTER Start playing.

ESC Stop playing.

l Load file.

t Load subtitle.

c Open skin browser.

p Open playlist.

r Open preferences.

If TV or DVB support compiled

h and k Select previous/next channel.

n Change norm.

u Change channel list.

Navigate menus (if DVNAV support)

keypad 8 Select button up.

keypad 2 Select button down.

keypad 4 Select button left.

keypad 6 Select button right.

keypad 5 Return to main menu.

keypad 7 Return to nearest menu (the order of preference is: chapter->title->root).

keypad ENTER Confirm choice.

Teletext support (if compiled)

X Switch teletext on/off.

Q and W Go to next/prev teletext page.

mouse control

button 3 and button 4 Seek backward/forward 1 minute.

button 5 and button 6 Decrease/increase volume.

joystick control

left and right Seek backward/forward 10 seconds.

up and down Seek forward/backward 1 minute.

button 1 Pause.

button 2 Toggle OSD states: none / seek / seek + timer / seek + timer + total time.

button 3 and button 4 Decrease/increase volume.

Personal tools