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.


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:



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.




Commands tagged video from sorted by
Terminal - Commands tagged video - 66 results
EXT=MOV; for i in *.$EXT; do HandBrakeCLI -Z Normal --optimize --use-opencl --width 1280 --height 720 -i "${i}" -o "${i//.$EXT}.mp4"; done
cvlc /path/to/file.avi -V caca
2014-06-13 16:10:36
User: tyzbit
Tags: video vlc

Use this command to watch video files on the terminal using VLC.

prerequisite: VLC and cvlc

sudo apt-get install vlc cvlc

ffmpeg -i $video -c:v prores -profile:v 2 -c:a copy ${video}.mov
ffmpeg -i "input.mts" -vcodec copy -acodec pcm_s16le "output.mov"
2014-01-24 13:00:07
User: lgarron

This *does not change the video encoding*, so it's fast (almost purely I/O-bound) and results in a file of nearly the same size.

However, OSX (and possibly other programs) will more easily play/seek the file when wrapped as MOV. For example, you can QuickLook the resulting file.

This basically does the same as the commercial ClipWrap program, except using the free program ffmpeg.

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

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.

transcode -i myvideo.avi -x mplayer="-utf8 -sub myvideo.srt" -o myvideo_subtitled.avi -y xvid
2013-11-19 11:03:00
User: thedod

If it's Hebrew [most probably all RTL languages. Comments?], add -flip-hebrew and -noflip-hebrew-commas to the mplayer switches:

transcode -i myvideo.avi -x mplayer="-utf8 -flip-hebrew -noflip-hebrew-commas -sub myvideo.srt" -o myvideo_subtitled.avi -y xvid
mplayer dvd://1 -dumpstream -dumpfile /tmp/file.mpg
2013-11-15 20:04:11
User: Mathieu
Tags: video mplayer rip

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

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

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.


sudo port install mplayer
mencoder mf://*.jpg -mf fps=50:type=jpg -ovc raw -oac copy -o out50fps.avi
2013-05-30 07:49:36
User: bhbmaster
Tags: video mencoder

Most of the commands require the jpegs a certain format, not this, it just follows alphabetical order. The same order you follow if you do "ls -lisah" from top to bottom, top frame is first, bottom is last...

This goes perfectly with a webcam timelapse... I have just the script for it:


avconv -y -f x11grab -r 12 -s 1600x900 -i :0.0 -f video4linux2 -i /dev/video0 -f alsa -i pulse -map 0:0 -vcodec rawvideo -pix_fmt yuv420p desktop.y4m -map 1:0 -vcodec rawvideo -pix_fmt yuv420p camera.y4m -map 2:0 audio.mp3
2013-05-26 13:36:55
User: alikhalil

Use avconv linux package to record input from camera, mic, and desktop for creating instructional videos. The generated video and audio files will required further processing to put in to a single useable video.

for i in *.VOB; do mplayer "$i" -ao pcm:file="${i%.*}.wav"; done
ffmpeg -loop 1 -i image.png -i sound.mp3 -shortest video.mp4
mencoder FILENAME.3gp -ovc lavc -lavcopts vcodec=msmpeg4v2 -oac mp3lame -lameopts vbr=3 -o FILENAME.avi
melt a.mp4 out=49 -track -blank 24 b.mp4 -transition luma in=25 out=49 a_track=0 b_track=1 -consumer avformat:out.mp4
2013-02-22 18:14:51
User: thhhhheesi

We take the first 50 frames of a.mp4 for track a, and 24 blank frames followed by b.mp4 for track b. We then create a transition from track a to track b starting from frame 25 and ending at frame 49.

The output is stored in out.mp4

To view the results without saving remove "-consumer avformat:out.mp4" from the end.

Documentation of the mlt framework and the melt command can be found here: http://www.mltframework.org/bin/view/MLT/Documentation

melt colour:black out=24 vid.mp4 -mix 25 -mixer luma colour:black out=24 -mix 25 -mixer luma -consumer avformat:out.mp4
2013-02-22 17:58:24
User: thhhhheesi

Replace vid.mp4 with the path to your original video file, and out.mp4 to the path where you want to save the new file.

To view the output first before saving, remove "-consumer avformat:out.mp4" from the end.

Documentation for mlt framework and melt command can be found here:


ffmpeg -i source.mpg -r 24 -f image2 still-%6d.png
2013-01-10 02:49:15
User: manuq

-i sets the source file

-r sets the output frame rate, set it to the same frame rate as the input to output each frame

-f sets the output format, trough it might be guessed by the extension

cvlc --input-slave pulse://<device> screen:// --screen-fps=15 --screen-top=0 --screen-left=0 --screen-width=640 --screen-height=480 --sout='#transcode{vcodec=FLV1,vb=1600,acodec=aac}:std{access=file,mux=ffmpeg{mux=flv},dst=viewport1.flv}'
2012-04-20 17:55:41
User: ysangkok

Errors in output don't matter. Stop recording: ctrl-c. Result playable with Flash too.

IMPORTANT: Find a Pulse Audio device to capture from: pactl list | grep -A2 'Source #' | grep 'Name: ' | cut -d" " -f2

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

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.

ffmpeg -i video.flv audio.ogg
2012-03-05 23:43:45
User: aminehmida

A simple command to extract audio from flv/mp4 video file.

Just change extentions...

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}'
totem-video-thumbnailer -pg 25 in_video out_png
ffmpeg -ss 5 -i video.avi -vframes 1 -s 320x240 thumb.jpg
2011-10-31 17:19:33
User: totti

Faster thumbnail creation than '-itsoffset'

ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
allVideos() { find ./ -type f -print0 | xargs -0 file -iNf - | grep ": video/" | cut -d: -f1; }
2011-08-19 11:58:59
User: totti
Functions: cut file find grep xargs

Videos are found using their MIME type. Thus no need to for an extension for the video file.

This is a efficent version of "jnash" cmd (4086). Thanks for jnash. This cmd will only show video files while his cmd show files having "video" anywhere in path.

egrep -i " connected|card detect|primary dev" /var/log/Xorg.0.log
2011-02-24 18:04:04
User: axelabs
Functions: egrep
Tags: video egrep xorg

The above one liner can be used to determine what card/driver is Xorg currently using. For additional information, see http://goo.gl/mDnWu

for i in $(curl -u <username> http://app.boxee.tv/api/get_queue | xml2 | grep /boxeefeed/message/object/url | cut -d "=" -f 2,3); do get_flash_videos $i; done
2011-01-03 13:43:03
User: Strawp
Functions: cut grep

Gets all videos in your boxee queue with a URL associated with them and attempts to download each using get_flash_videos