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 ffmpeg from sorted by
Terminal - Commands tagged ffmpeg - 61 results
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
0

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
1

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
3

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
0

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
0

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

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
1

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
12

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
0

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

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

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
2

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
1

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
0

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

Just change extentions...

mkdir rotated; for v in *.3gp; do ffmpeg -i $v -vf transpose=2 -vcodec ffv1 rotated/${v/3gp/avi} ; done
2012-02-04 18:20:04
User: keturn
Functions: mkdir
5

Takes all the .3gp files in the directory, rotates them by 90 degrees, and saves them in the lossless ffv1 encoding.

If this rotates in the wrong direction, you may want transponse=1

Re-encoding to ffv1 may result in a significant increase in file size, as it is a lossless format. Other applications may not recognize ffv1 if they don't use ffmpeg code. "huffyuv" might be another option for lossless saving of your transformations.

The audio may be re-encoded as well, if the encoding used by your 3gp file doesn't work in a avi container.

ffprobe video.flv
2012-01-02 19:56:20
User: clusterdoc
Tags: ffmpeg
2

ffprobe is specially intended to get video information

ffmpeg -ss 5 -i video.avi -vframes 1 -s 320x240 thumb.jpg
2011-10-31 17:19:33
User: totti
2

Faster thumbnail creation than '-itsoffset'

ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
ffmpeg -f alsa -i default -f x11grab -s sxga -r 10 -i :0.0 -f mp4 -s vga -sameq out.mp4
2011-09-18 15:10:56
User: kev
Tags: ffmpeg
0

sxga ==> 1280x1024

vga ==> 800x600

------------------------------------------------

xwininfo -root | grep geometry

------------------------------------------------