Hide

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.


If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Hide

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:

Hide

News

2011-03-12 - Confoo 2011 presentation
Slides are available from the commandlinefu presentation at Confoo 2011: http://presentations.codeinthehole.com/confoo2011/
2011-01-04 - Moderation now required for new commands
To try and put and end to the spamming, new commands require moderation before they will appear on the site.
2010-12-27 - Apologies for not banning the trolls sooner
Have been away from the interwebs over Christmas. Will be more vigilant henceforth.
2010-09-24 - OAuth and pagination problems fixed
Apologies for the delay in getting Twitter's OAuth supported. Annoying pagination gremlin also fixed.
Hide

Tags

Hide

Functions

Commands tagged mplayer from sorted by
Terminal - Commands tagged mplayer - 54 results
ID=52DnUo6wJto;mplayer -fs $(echo "http://youtube.com/get_video.php?&video_id=$ID$(wget -qO - 'http://youtube.com/watch?v='$ID | perl -ne 'print $1."&asv=" if /^.*(&t=.*?)&.*$/; print "&fmt=".$1 if /^.*&fmt_map=(22).*$/')")
2010-09-17 17:06:55
User: lslah
Functions: echo
6

Streams youtube video with v=ID directly into the mplayer.

If exists, it uses the HD-quality stream.

If you don't want to watch it in HD-quality, you can use the shorter form:

ID=52DnUo6wJto; mplayer -fs $(echo "http://youtube.com/get_video.php?&video_id=$ID$(wget -qO - 'http://youtube.com/watch?v='$ID | perl -ne 'print $1."&asv=" if /^.*(&t=.*?)&.*$/')")
alias mplayer='mplayer -stop-xscreensaver'
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
2010-07-18 02:11:39
User: zed
Functions: ls tail
12

requires "youtube-dl" -- sure you can do this with wget and some more obscurity but why waste your time when this great tool is available?

the guts consist of mplayer converting a video to a gif -- study this command and read the man page for more information

mplayer video.flv -ss 00:23 -endpos 6 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound

generates a 6 second gif starting at 23 seconds of play time at 5 fps and a scale of 400x300

start time (-ss)/end time (-endpos) formats: 00:00:00.000

end time should be relative to start time, not absolute. i.e. -endpos 5 == seconds after 0:42 = 0:47 end point

play with fps and scale for lower gif sizes

the subshell is a solution for the -b flag on youtube-dl which downloads the best quality video, sometimes, which can be various video formats $(ls ${url##*=}*| tail -n1)

zenity --list --width 500 --height 500 --column 'radio' --column 'url' --print-column 2 $(curl -s http://www.di.fm/ | awk -F '"' '/href="http:.*\.pls.*96k/ {print $2}' | sort | awk -F '/|\.' '{print $(NF-1) " " $0}') | xargs mplayer
2010-04-28 23:45:35
User: polaco
Functions: awk sort xargs
15

This is a very simple and lightweight way to play DI.FM stations

For a more complete version of the command with proper strings in the menu, try: (couldnt fit in the command field above)

zenity --list --width 500 --height 500 --title 'DI.FM' --text 'Pick a Radio' --column 'radio' --column 'url' --print-column 2 $(curl -s http://www.di.fm/ | awk -F '"' '/href="http:.*\.pls.*96k/ {print $2}' | sort | awk -F '/|\.' '{print $(NF-1) " " $0}') | xargs mplayer

This command line parses the html returned from http://di.fm and display all radio stations in a nice graphical menu. After the radio is chosen, the url is passed to mplayer so the music can start

dependencies:

- x11 with gtk environment

- zenity: simple app for displaying gtk menus (sudo apt-get install zenity on ubuntu)

- mplayer: simple audio player (sudo apt-get install mplayer on ubuntu)

mplayer -playlist <(find $PWD -type f)
2010-04-17 00:20:08
User: rkulla
Functions: find
0

Press > or < to go to the next or previous track. Space to toggle play/pause, etc.

It creates a temp file descriptor. To see where the file descriptor gets created type: echo <(echo foo)

This works better than running find first, then piping to mplayer with xargs or something, because that won't let you use keyboard shortcuts.

mplayer -novideo something.mpg
mplayer -vc null -vo null -ao pcm <input video file> -ss <start> -endpos <end>
2010-02-26 11:00:24
User: ivanatora
Tags: mplayer
4

mplayer -vc null -vo null -ao pcm Firefly\ ep\ 10.avi -ss 195 -endpos 246

Will create file audiodump.wav with audio from second 195 to second 246 (the opnening theme).

mplayer -vo null something.mpg
2010-02-23 16:36:36
User: foremire
Tags: mplayer
11

Sometimes you only want to linsten the audio while output the video will be a waste of CPU resource and an annoying window. With option -vo null, you will enjoy the audio!

mplayer dvd:// -softvol -softvol-max 500
2009-12-30 18:19:44
User: kanzure
Tags: mplayer sound
7

use '0' and '9' to increase/decrease volume. this is useful on laptops with low speaker volume.

bbcradio() { local s PS3="Select a station: ";select s in 1 1x 2 3 4 5 6 7 "Asian Network an" "Nations & Local lcl";do break;done;s=($s);mplayer -playlist "http://www.bbc.co.uk/radio/listen/live/r"${s[@]: -1}".asx";}
2009-11-14 08:17:03
User: eightmillion
22

This command lets you select from 10 different BBC stations. When one is chosen, it streams it with mplayer.

Requires: mplayer with wma support.

find -type f -name "*.avi" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
2009-09-24 15:50:39
User: syssyphus
Functions: find perl printf tail xargs
8

change the *.avi to whatever you want to match, you can remove it altogether if you want to check all files.

(sp-sc sop://broker.sopcast.com:3912/6002 3900 8900 &>/dev/null &); sleep 10; mplayer http://localhost:8900/tv.asf
2009-09-19 17:46:13
User: Escher
Functions: sleep
1

Get sopcast links for live sports from http://myp2p.eu (for example)

Get sp-sc or sp-auth binary by googling (sopcast + linux)

eg http://www.jbg.f2s.com/sp-sc.gz

Requires the 32bit libstdc++5 package.

After exiting mplayer, type 'killall sp-sc'

mplayer -fs -vf screenshot,mirror tv://
2009-09-17 05:15:42
User: kamathln
Tags: mplayer webcam
1

This directly puts the "mirror" into fullscreen, and lets you take photos by pressing the 's' key. I bet appearance conscious people will have keyboard shortcut for this command by now.

mplayer tv:// -vf mirror
mplayer tv:// -tv driver=v4l2:width=640:height=480:device=/dev/video0:fps=30:outfmt=yuy2
2009-09-15 19:41:41
User: ivalladt
5

View webcam output using mplayer, with correct fps and outfmt settings according to my webcam model.

id="dMH0bHeiRNg";mplayer -fs http://youtube.com/get_video.php?video_id=$id\&t=$(curl -s http://www.youtube.com/watch?v=$id | sed -n 's/.*, "t": "\([^"]*\)", .*/\1/p')
2009-08-13 14:16:01
User: matthewbauer
Functions: id sed
12

The original doesn't work for me - but this does. I'm guessing that Youtube updated the video page so the original doesn't work.

mplayer -vo caca foo.avi
2009-05-25 09:29:24
User: farwarx
-11

Permet de lire une video dans une console, meme sans interface graphique.

Interet limite, mais a connaitre au cas ou.

mplayer -fs cdda://9 -ao pcm:file=track9.wav
2009-05-23 23:23:45
User: dcabanis
3

Using mplayer to extract audio file from a CD

mencoder -ovc copy -nosound ./movie.mov -o ./movie_mute.mov
2009-05-17 11:56:22
User: angleto
2

create a copy of a video file without the audio tracs

find . -name '*.m4a' | xargs -I audiofile mplayer -ao pcm "audiofile" -ao pcm:file="audiofile.wav"
mencoder dvd://1 -aid 128 -o track-1.avi -oac copy -ovc lavc -lavcopts vcodec=mpeg4
2009-05-16 00:08:57
User: dstahlke
2

Substitute whatever track number you want into the "dvd://1" parameter. The "-aid 128" is to select the English language.

alias somafm='read -p "Which station? "; mplayer --reallyquiet -vo none -ao sdl http://somafm.com/startstream=${REPLY}.pls'
2009-05-05 12:13:46
User: denzuko
Functions: alias
-2

This is the alias command that I discussed in my prior release which you can add to your ~/.bashrc.

This command asks for the station name and then connects to somafm, Great for those who have linux home entertainment boxes and ssh enabled on them, just for the CLI fiends out there ( I know I'm one of them ;)

You can find future releases of this and many more scripts at the teachings of master denzuko - denzuko.co.cc.

read -p "Which station? "; mplayer --reallyquiet -vo none -ao sdl http://somafm.com/startstream=${REPLY}.pls
2009-05-04 00:26:19
User: denzuko
Functions: read
11

This command asks for the station name and then connects to somafm, Great for those who have linux home entertainment boxes and ssh enabled on them, just for the CLI fiends out there ( I know I'm one of them ;)

Also, don't forget to add this as alias(ie alias somafm="read -p 'Which Station? "; mplayer --reallyquite -vo none -ao sdl

mplayer -framedrop -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all
2009-04-27 15:40:55
User: baergaj
Tags: video mplayer
11

Certain codecs in high res don't play so well on my Dell Mini 9. Using this command, I can play just about anything and it keeps the sound in sync to boot!

mplayer -vo aa <video file>