Tuesday, 13 March 2012

Mplayer Command Examples

mplayer is a media player, its mainly used to play audio or video. 

What I like about it is how you can use it in the command line.

For example to play a audio file.
maplyer mediafile.mp3
Its as simple as that.

For a video its slightly differnt. Mplayer does not support dvd menu's which is a bit of a pain really so you need to do the following
mplayer dvd://titlenumber

obviously titlenumber needs to be replaced with your desired title number. Xine is a lot better for DVD menu's but thats a whole other kettle of fish

If you wish to move forward in a track or film there a a whole load of keyboard short cuts avalible here
I know your thinking "whats the big deal?" but the real reason I use mplayer is to rip audio from video files.
I use this a lot in conjunction with the youtube-dl program. 
mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile someVideo nameOfAudioFile.mp3

I've taken the liberty off adding a selection of commands below:

Play all files in directory
$mplayer -playlist <(find "$PWD" -type f)

Stream Youtube directly to mplayer
$yt () mplayer -fs -quiet $(youtube-dl -g "$1")

Create an animated gif of a youtube video
url=http://www.youtube.com/watch?v=V5bYDhZBFLA; youtube-dl -b $url; mplayer $(ls ${url##*=}*| tail -n1) -ss 00:57 -endpos 10 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound

use mplayer to play just the audio from a video
mplayer -vo null something.mpg

Shuffle songs in mplayer with no output
mplayer -shuffle $HOME/music/* $HOME/Dropbox/Music/*/* $HOME/Dropbox/Music/*/*/* etc. >> /dev/null 2>&1

No comments:

Post a Comment