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.

Universal configuration monitoring and system of record for IT.
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

May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!
Hide

Top Tags

Hide

Functions

Hide

Credits

Commands tagged mplayer from sorted by
Terminal - Commands tagged mplayer - 57 results
pyt() { youtube-dl -q --max-downloads 1 --no-playlist --default-search ${2:-ytsearch} "$1" -o - | mplayer -vo null /dev/fd/3 3<&0 </dev/tty; }
2015-07-27 15:19:59
User: snipertyler
2

Same as other command, however uses youtube-dl internal search (thanks to qoxxxx mentioning this)

It does however seem to be a little buggy and youtube-dl crashes sometimes.

##

pyt 'Stairway to heaven - Led Zeppelin'

pyt 'brain damage - Pink Floyd'

No web browser or even X needed. Just a cli and internet connection!

mplayer is pauseable and can skip ahead

This may break if youtube changes their search html.

pyt() { id=$(curl -s 'https://www.youtube.com/results?search_query='$(tr \ + <<<"$1") | grep -om3 '"[[:alnum:]]\{11\}"' | awk NR==3 | tr -d \"); youtube-dl -q 'https://www.youtube.com/watch?v='"$id" -o - | mplayer -vo null /dev/fd/3 3<&0 </dev/tty; }
2015-07-20 05:30:27
User: snipertyler
Functions: awk grep tr
3

pyt 'Stairway to heaven - Led Zeppelin'

pyt 'brain damage - Pink Floyd'

No web browser or even X needed. Just a cli and internet connection!

mplayer is pauseable and can skip ahead

This may break if youtube changes their search html.

syt() { pipe=`mktemp -u`; mkfifo -m 600 "$pipe" && for i in "$@"; do youtube-dl -qo "$pipe" "$i" & mplayer "$pipe" || break; done; rm -f "$pipe"; }
2015-03-14 01:48:20
User: snipertyler
Functions: mkfifo rm
3

Streams youtube-dl video to mplayer.

Usage:

syt 'youtube.com/link' 'anotherlinkto.video'

Uses mplayer controls

mplayer -dumpstream -dumpfile stream_video_name url
2013-12-13 18:28:16
User: pascalfares
0

1. Copy the url of the streaming video mms://etc... or http://...

2. Open up a terminal.

3. the command

4. Wait for the stream dump.

mplayer dvd://1 -dumpstream -dumpfile /tmp/file.mpg
2013-11-15 20:04:11
User: Mathieu
Tags: video mplayer rip
0

This simple command will copy a DVD losslessly to your drive and remove the encryption.

python2 -c 'import urllib2 as u, sys as s, json as j, subprocess as p;p.call(["mplayer", u.urlopen(j.loads(u.urlopen("http://ex.fm/api/v3/song/search/%s" % "+".join(s.argv[1:])).read())["songs"][0]["url"]).geturl().split("#")[0]])' lenny kravitz fly away
2013-09-21 02:25:51
User: nagev
Functions: as
4

Just give it an artist and/or song at the end of the command as shown.

cat part1.avi part2.avi part3.avi > tmp.avi && mencoder -forceidx -oac copy -ovc copy tmp.avi -o output.avi && rm -f tmp.avi
2013-09-05 01:47:22
User: sudopeople
Functions: cat rm
4

Useful for when you download movies split into < 700mb parts.

Credit to rich @ http://superuser.com/questions/318640/merge-avi-files-without-recoding-in-mac-os-x-lion

mencoder is generally included with mplayer.

MacPorts:

sudo port install mplayer
for i in *.flv *.mkv *.avi; do mplayer -ao null -vo null -ss 0 -endpos 1 >/dev/null "$i" 2> >(grep -qi error && echo >&2 "$i seems bad"); done
2013-08-20 22:23:11
User: sputnick
Functions: echo grep
0

If you want avoid to be annoyed when playing your favourite video files with your video player, first run this command to stash wrong files (and test tricks to play these wrong files).

mplayer -nolirc http://5253.live.streamtheworld.com/VIRGINRADIO_DUBAIAAC
2013-01-09 09:00:41
Tags: mplayer
1

Above command will play Virgin Radio Dubai

mplayer <(tail -fc +0 <filename>)
2012-04-30 07:28:42
User: gtmanfred
Functions: tail
0

It will just start playing and will not stop at the point that it has downloaded up to when the video starts

find /path/to/dir -iname "*.ext" -print0 | xargs -0 mplayer -really-quiet -cache 64 -vo dummy -ao dummy -identify 2>/dev/null | awk '/ID_LENGTH/{gsub(/ID_LENGTH=/,"")}{SUM += $1}END{ printf "%02d:%02d:%02d\n",SUM/3600,SUM%3600/60,SUM%60}'
2012-03-11 12:28:48
User: DarkSniper
Functions: awk find printf xargs
0

Improvement on Coderjoe's Solution. Gets rid of grep and cut (and implements them in awk) and specifies some different mplayer options that speed things up a bit.

youtube-dl -o bun.flv http://www.youtube.com/watch?v=SfPLcQhXpCc; mplayer bun.flv -ss 03:16 -endpos 5 -vo jpeg:outdir=bun:quality=100:smooth=30:progressive -vf scale=320:240 -nosound; convert -delay 4 -loop 0 bun/*.jpg bun.gif
2012-01-05 17:53:22
User: joeyliechty
0

Creates a better looking gif than the original post via imagemagick processing high quality jpgs, rather than converting directly to gif from the video itself.

mplayer -endpos 0.1 -vo null -ao null -identify *.avi 2>&1 |grep ID_LENGTH |cut -d = -f 2|awk '{SUM += $1} END { printf "%d:%d:%d\n",SUM/3600,SUM%3600/60,SUM%60}'
mplayer -shuffle $HOME/music/* $HOME/Dropbox/Music/*/* $HOME/Dropbox/Music/*/*/* etc. >> /dev/null 2>&1
mplayer -shuffle $HOME/music/* $HOME/music/*/* $HOME/music/*/*/* etc.
say() { if [[ "${1}" =~ -[a-z]{2} ]]; then local lang=${1#-}; local text="${*#$1}"; else local lang=${LANG%_*}; local text="$*";fi; mplayer "http://translate.google.com/translate_tts?ie=UTF-8&tl=${lang}&q=${text}" &> /dev/null ; }
2011-11-03 00:33:11
User: marrowsuck
8

Google text-to-speech in your local language or in language of choice via country code switch (ISO 639-1).

say() { local IFS=+;mplayer "http://translate.google.com/translate_tts?q=$*"; }
say() { mplayer "http://translate.google.com/translate_tts?q=$1"; }
2011-09-08 03:34:24
User: daa
15

Usage examples:

say hello

say "hello world"

say hello+world

cat subtitles.txt | perl -pe 's/} /}/g; s/{(\d+)}/=1=/; $f1=(24/25*$1); s/{(\d+)}/=2=/; $f2=(24/25*$1); $f1=~s/\..*//; $f2=~s/\..*//; s/=1=/{$f1}/; s/=2=/{$f2}/; ' > subtitles_newfps.txt
2011-07-30 15:34:43
User: ciekawy
Functions: cat perl
1

this command example converts to 25 fps subtitles that were originally created for 24 fps movie

mplayer -af volnorm=2:0.75 dvd://
2011-07-24 07:26:51
User: h3xx
Tags: mplayer volume
2

Works really well for playing DVDs, which have the volume turned way down for some reason. The `2' method is better IMHO because it will adjust to changing loud/soft parts.

If you want to add it to your ~/.mplayer/config:

# format: volnorm[=method:target]

# method:

# 1: use single sample (default)

# 2: multiple samples

# target:

# default is 0.25

af-add=volnorm=2:0.75

mplayer -playlist <(find "$PWD" -type f)
2011-07-24 03:27:03
User: h3xx
Functions: find
Tags: mplayer fd
0

Skip forward and back using the < and > keys. Display the file title with I.

mplayer -fs -cookies -cookies-file /tmp/cookie.txt $(youtube-dl -g --cookies /tmp/cookie.txt "http://www.youtube.com/watch?v=PTOSvEX-YeY")
dvgrab - | mplayer -
(sp-sc sop://broker.sopcast.com:3912/80562 8908 10999 &>/dev/null &); sleep 10; wait $(vlc http://localhost:10999); killall sp-sc
2011-04-06 00:08:38
User: Bonster
Functions: killall sleep wait
0

requires sp-auth installed

This command will auto kill sp-sc after vlc is closed, so u wont have to do it manually

mplayer -vo fbdev $1 -fs -subcp ${2:-cp1251} -vf scale=${3:-1280:720}
2011-03-04 00:55:55
User: vkolev
-1

It's made for a script use, where you have 3 parameters:

1. parameter is the filename

2. (optional) the encoding for subtitles

3. (optional) the scaling of the video, since fullscreen doesn't mean that the video will be scaled.