Difference between revisions of "Mplayer notes"
Line 30: | Line 30: | ||
<pre> | <pre> | ||
mplayer dvd://1 -dvd-device /home/user/DVD_Directory | mplayer dvd://1 -dvd-device /home/user/DVD_Directory | ||
+ | </pre> | ||
+ | |||
+ | == Play a video from an unfinished RAR download == | ||
+ | |||
+ | You can play a video in a rar file before it has even finished downloading. Use the single dash option with `mplayer` to play video from a pipe. Use 'p' option on unrar to send the file data from a rar file to stdout. | ||
+ | |||
+ | <pre> | ||
+ | unrar p "movie_download.part01.rar" | mplayer - | ||
</pre> | </pre> | ||
Revision as of 03:43, 3 September 2008
These are my notes on MPlayer and MEncoder. These are my favorite video tools.
Contents
- 1 Pkay HD video on low performance system
- 2 Play a DVD ISO
- 3 Play a DVD VIDEO_TS directory structure
- 4 Play a video from an unfinished RAR download
- 5 Convert video file to a sequence of images
- 6 Play a sequence of images
- 7 Convert a sequence of images to video file
- 8 Create a VCD, SVCD, or DVD
- 9 Display motion vectors
- 10 Configure mplayer under Gnome
- 11 Build mplayer on Ubuntu Overview
- 12 Build MPlayer script
Pkay HD video on low performance system
This allows me to play HD video content (1080P) on my MacMini (running Linux) which has just barely the power to handle HD. This lowers quality a little bit, but it's hardly noticeable.
mplayer -lavdopts lowres=2:fast:skiploopfilter=all:threads=8 high_def_video.h264.ts
Play a DVD ISO
This will play the first chapter off a DVD ISO disk image.
mplayer dvd://1 -dvd-device disk_image.iso
This works with mencoder for transcoding DVD. Note that you are selecting a certain audio track that you have to put it before the dvd://1 option. I'm not sure why.
mencoder -aid 129 dvd://1 -dvd-device 'disk_image.iso' -o 'video.avi' -ovc lavc -oac copy -lavcopts vcodec=mpeg4:vbitrate=1500:mbd=2:aspect=4/3:vpass=1
Play a DVD VIDEO_TS directory structure
This will play the first chapter off a DVD VIDEO_TS directory structure where "DVD_Directory" should be the directory above the VIDEO_TS directory. This is similar to playing a DVD ISO.
mplayer dvd://1 -dvd-device /home/user/DVD_Directory
Play a video from an unfinished RAR download
You can play a video in a rar file before it has even finished downloading. Use the single dash option with `mplayer` to play video from a pipe. Use 'p' option on unrar to send the file data from a rar file to stdout.
unrar p "movie_download.part01.rar" | mplayer -
Convert video file to a sequence of images
This will convert a video file to a sequence of JPEG images:
mplayer -nosound -vo jpeg input.avi
You might prefer PNG as an intermediate format for better quality:
mplayer -nosound -vo png input.avi
Play a sequence of images
This will play all jpeg images in the directory as a video. No need to first convert them to a video file. This will work with most image types. Playing a JPEG sequence is shown here:
mplayer "mf://*.jpg" -mf fps=24
Convert a sequence of images to video file
Same idea as sequence playback, but use mencoder to make a video file:
mencoder "mf://*.jpg" -mf fps=25 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4
Create a VCD, SVCD, or DVD
Install vcdimager and cdrdao. Both vcdimager and cdrdao are also available through apt on Ubuntu. For DVD you will also need dvdauthor. For, DVDs these instructions create an ISO disk image without a menu. For information on creating a DVD menu read the man page for dvdauthor. These instructions also assume NTSC. Read the mencoder help files for information on creating PAL disks.
VCD
mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xvcd -vf \ scale=352:240,harddup -srate 44100 -af lavcresample=44100 -lavcopts \ vcodec=mpeg1video:keyint=18:vrc_buf_size=327:vrc_minrate=1152:\ vbitrate=1152:vrc_maxrate=1152:acodec=mp2:abitrate=224 -ofps 30000/1001 \ -o <filename>.mpg <filename>.avi vcdimager -t vcd2 -l "Movie Title" -c <filename>.cue -b <filename>.bin <filename>.mpg cdrdao write --device /dev/cdrom <filename>.cue
SVCD
mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \ scale=480:480,harddup -srate 44100 -af lavcresample=44100 -lavcopts \ vcodec=mpeg2video:mbd=2:keyint=18:vrc_buf_size=917:vrc_minrate=600:\ vbitrate=2500:vrc_maxrate=2500:acodec=mp2:abitrate=224 -ofps 30000/1001 \ -o <filename>.mpg <filename>.avi vcdimager -t svcd -l "Movie Title" -c <filename>.cue -b <filename>.bin <filename>.mpg cdrdao write --device /dev/cdrom <filename>.cue
DVD NTSC WIDESCREEN 16/9
I have a simple script which does this. This will take any video file and burn it to a widescreen DVD-Video format. Click here to download: avi2dvd
mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \ -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 \ -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\ keyint=18:vstrict=0:acodec=ac3:abitrate=192:aspect=16/9 -ofps 30000/1001 \ -o <filename>.mpg <filename>.avi dvdauthor -o dvd/ -t <filename>.mpg dvdauthor -o dvd/ -T mkisofs -dvd-video -o disk_image.iso dvd/ growisofs -dvd-compat -Z /dev/dvd=disk_image.iso # You can skip mkisofs step if you want to burn just one DVD. # Use this growisofs command instead: growisofs -dvd-compat -dvd-video -V "<volumelabel>" -Z /dev/dvd dvd/
DVD NTSC FULL 4/3
mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd:tsaf \ -vf scale=720:480,harddup -srate 48000 -af lavcresample=48000 \ -lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:\ keyint=18:vstrict=0:acodec=ac3:abitrate=192:aspect=4/3 -ofps 30000/1001 \ -o <filename>.mpg <filename>.avi dvdauthor -o dvd/ -t <filename>.mpg dvdauthor -o dvd/ -T mkisofs -dvd-video -o disk_image.iso dvd/ growisofs -dvd-compat -Z /dev/dvd=disk_image.iso # You can skip mkisofs step if you want to burn just one DVD. # Use this growisofs command instead: growisofs -dvd-compat -dvd-video -V "<volumelabel>" -Z /dev/dvd dvd/
Note that /dev/cdrom should be a sym link to the real CDR burning device. This is probably already setup for you. On my system, /dev/cdrom is a sym link to /dev/scd0.
Display motion vectors
This might come in use for debugging:
mplayer -lavdopts vismv=1 input.avi
Configure mplayer under Gnome
I'm not a Gnome fan, but I've learned to live with it out of laziness. A few things make it more tolerable.
gconftool-2 --type string --set /desktop/gnome/volume_manager/autoplay_dvd_command "mplayer dvd://" cp /usr/share/applications/defaults.list /usr/share/applications/defaults.list_backup sed -e 's/totem.desktop/mplayer.desktop/g' /usr/share/applications/defaults.list_backup > /tmp/defaults.list /tmp/defaults.list /usr/share/applications/defaults.list
Build mplayer on Ubuntu Overview
This is a very brief overview. See the #Build MPlayer script for everything that really needs to be done.
aptitude -q -y install libpng-dev libsvga1-dev zlib1g-dev aptitude -q -y install libgtk1.2-common libglib1.2 libgtk1.2 libgtk-dev aptitude -q -y install x-window-system-dev libx11-dev libxv-dev aptitude -q -y install lame liblame-dev libtwolame-dev libavcodec-dev ./configure --disable-ass --enable-largefiles --enable-x11 --enable-xv --enable-svga make make install
Build MPlayer script
This will build MPlayer with svga, xv, and x11 output support. This is intended for an Ubuntu system, but might work on others. This should work on the majority of systems with a fresh Ubuntu installation with UNIVERSE support. Remove libsvga support for use on a totally stock Ubuntu with no UNIVERSE support.
This script pretty much automates everything. It will download the source code, codecs, and fonts from mplayerhq.hu and install everything. Normally I use Ubuntu packages, but in this instance I find that building from source works better. It's easier and I get every single codec that is available from mplayerhq.hu.
'x11' output gives a little better quality. 'xv' output quality isn't quite as nice, but it is faster (less CPU) and it can be dynamically resized or made fullscreen. The 'x11' video output has a fixed size even if you press 'f' for fullscreen (it just gets centered in the screen). 'xv' sometimes has a problem where only one 'xv' resource can be used at a time and some other process might lock 'xv' so you can only play one video at a time.
Download mplayer_build.sh <include svncat src="file:///home/svn/src/shell/mplayer_build.sh" highlight="sh" />