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.

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:



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!

Top Tags





Commands tagged ffmpeg from sorted by
Terminal - Commands tagged ffmpeg - 65 results
cat *.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 out.mp4
i=in.swf; dump-gnash -1 -j 1280 -k 720 -D "${i%.*}".bgra@12 -A "${i%.*}".wav "${i}"
2015-05-06 23:52:39
User: mhs

This will dump a raw BGRA pixel stream and WAV which must then be converted to video:

ffmpeg -f rawvideo -c:v rawvideo -s 1280x720 -r 12 -pix_fmt bgra -i "${i%.*}".bgra -c:v libx264 -preset veryslow -qp 0 -movflags +faststart -i "${i%.*}".wav -c:a libfdk_aac -b:a 384k "${i%.*}".mp4 ; rm "${i%.*}".bgra "${i%.*}".wav

Our example generates an x264/720p/12fps/AAC best-quality MP4.

To get dump-gnash, first install the build-dependencies for gnash (this step is OS-specific). Then:

git clone http://git.savannah.gnu.org/r/gnash.git ; cd gnash ; ./autogen.sh ; ./configure --enable-renderer=agg --enable-gui=dump --disable-menus --enable-media=ffmpeg --disable-jemalloc ; make
ffmpeg -i "$fin" -c copy -copyts "${fin%.*}.mp4"
avconv -i ka-ching.flv -acodec copy -vcodec copy ka-ching.mkv
ffmpeg -i input.mpg -deinterlace -pix_fmt yuv420p -vcodec libx264 -preset slow -vprofile high -trellis 2 -crf 20 -ac 2 -ab 192k -f mp4 -ss 5:00.000 -to 25:00.000 output.avi
ffmpeg -acodec copy -vcodec copy -ss 00:05:00 -t 00:20:00 -i file.mp4 file_cropped.mp4
find -type f -exec bash -c 'if ffmpeg -i "{}" 2>&1 | grep -qi h264 ; then echo "{}"; fi' \;
youtube-dl -c -o "%(title)s" -f 18 https://www.youtube.com/watch?v=5qSCKUCjdKg
2014-06-12 23:31:55
User: tg3793

Before you use this command you want to replace everything after the "https:" with the url of the video which you want to download. This string and it's switches will use "youtube-dl" to download the Youtube url into the directory/folder where it is called from. It will output the video using the same name as Youtube uses.

ffmpeg -i input_file.mp4 -strict experimental output_file.webm
2014-05-08 01:45:33
User: angryunicorn
Tags: ffmpeg

If you're using the experimental vorbis encoder (homebrew version of libffmpeg)

ffmpeg -i file.ext -acodec copy -vn out.ext
2014-04-25 14:24:57
User: snipertyler
Tags: ffmpeg

This removes the video and subsequent file size and directly copies the audio.

curl 'AudioStream' | ffmpeg -i - -acodec libvorbis file.ogg
2014-03-31 02:07:20
User: snipertyler

This encodes it in ogg format.

Does on-the-fly encoding of the incoming stream.

Great for radio streams as they're often flv format.

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.

FOR %I IN (*.mp4) DO \Tools\ffmpeg\bin\ffmpeg.exe -i "%I" "%~nI.mpeg"
ffmpeg -loop 1 -i image.png -i sound.mp3 -shortest video.mp4
-y -r 1 -t 3 -f video4linux2 -vframes 1 -s sxga -i /dev/video0 ~/webcam-$(date +%m_%d_%Y_%H_%M).jpeg
2013-02-27 05:32:03
User: navyjeff
Functions: date

Take a picture from your webcam and save it to a jpeg.

A very slightly modified version of MarxBro's command.

sox -d -p | ffmpeg -i pipe:0 -f flv -preset ultrafast -tune zerolatency rtmp://localhost/live/livestream
2013-02-20 12:04:49
User: adimania

sox (SOund eXchange) can capture the system audio be it a browser playing youtube or from hardware mic and can pipe it to ffmpeg which encodes it into flv and send it over rtmp.

Tested using Red5 rtmp server.

mp4box -info video.mp4
read && ffmpeg -y -r 1 -t 3 -f video4linux2 -vframes 1 -s sxga -i /dev/video0 ~/webcam-$(date +%m_%d_%Y_%H_%M).jpeg
2013-01-17 11:37:09
User: MarxBro
Functions: date read

This command takes a 1280x1024 p picture from the webcam.

If prefer it smaller, try changing the -s parameter: qqvga is the tiniest, vga is 640x480, svga is 800x600 and so on.

Get your smile on and press enter! :)

ffmpeg -i source.mpg -f s16le -acodec pcm_s16le audio.raw
2013-01-10 02:54:04
User: manuq

-i sets the source file

-f and -acodec both set the output to be raw audio, PCM signed 16-bit little endian

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

a=$(xwininfo |gawk 'BEGIN {FS="[x+ \t]*"} /-geometry/ {print int(($3+1)/2)*2"x"int(($4+1)/2)*2"+"$5"+"$6}') ; echo ${a} ; ffmpeg -f x11grab -s ${a} -r 10 -i :0.0 -sameq -f mp4 -s wvga -y /tmp/out.mpg
2012-08-31 14:48:41
User: dwygo
Functions: echo gawk

Now we can capture only a specific window (we have to chose by clicking on it)

ffmpeg complains about "Frame size must be a multiple of 2" so we calculate the upper even number with (g)awk trickery.

We remove the grep, we are already using (g)awk here ....why losing time with grep !!! ;)

ffmpeg -i concat:VTS_02_1.VOB\|VTS_02_2.VOB\|VTS_02_3.VOB\|VTS_02_4.VOB\|VTS_02_5.VOB -map 0:v:0 -map 0:a:0 -codec:a libvo_aacenc -ab 128 -codec:v libx264 -vpre libx264-ipod640 movie.mp4
2012-05-10 23:51:19
User: br3wski3
Tags: ffmpeg dvd

Alternative, imho better, using the concat protocol

ffmpeg -i input.ogv -vol $((256*4)) -vcodec copy output.ogv
ssh user@host "ffmpeg -f x11grab -r 5 -s 1280x720 -i :0 -f avi -" | ffplay - &>/dev/null
2012-05-01 06:26:49
User: buhrietoe
Functions: ssh
Tags: ssh ffmpeg ffplay

Play with the framerate option '-r' to scale back bandwidth usage.

The '-s' option is the captured screan area, not the rescaled size. If you want to rescale add a second '-s' option after '-i :0'. Rescaling smaller will also decrease bandwidth.

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...