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.
mpalyer mediafile.mp3
Its as simple as that.

For a video its slightly different. 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 title number needs to be replaced with your desired title number. Xine is a lot better for DVD menu's but that's a whole other kettle of fish

If you wish to move forward in a track or film there are a whole load of keyboard short cuts available here

I know your thinking "what's 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")

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