Commands tagged ffmpeg (83)

  • I'm not well enough versed in the differences between ffmpeg & mencoder to know which one is better.


    0
    ffmpeg -i file.flv file.avi
    matthewdavis · 2010-09-02 18:18:38 3
  • yt2mp3(){ for j in `seq 1 301`;do i=`curl -s gdata.youtube.com/feeds/api/users/$1/uploads\?start-index=$j\&max-results=1|grep -o "watch[^&]*"`;ffmpeg -i `wget youtube.com/$i -qO-|grep -o 'url_map"[^,]*'|sed -n '1{s_.*|__;s_\\\__g;p}'` -vn -ab 128k "`youtube-dl -e ${i#*=}`.mp3";done;} squeezed the monster (and nifty ☺) command from 7776 from 531 characters to 284 characters, but I don't see a way to get it down to 255. This is definitely a kludge!


    0
    Command in description (Your command is too long - please keep it to less than 255 characters)
    __ · 2011-02-03 08:25:42 5
  • Gives stereo, 16bit, 44.1kHz (default in Ubuntu/Medibuntu ffmpeg). -aq 2 = 220-250kbit/s VBR, lower number is better quality. 2 or 3 should be good for most people. If you want the best mp3 q you should remove -aq and use -ab 320k to get 320kbit/s, but that is probably overkill for most .flv videos.


    0
    ffmpeg -i input.flv -aq 2 output.mp3
    maedox · 2011-02-16 15:05:41 3
  • ffmpeg [source specification if needed] -i $src -an -vcodec libx264 -coder 0 -threads 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -level 13 -g 15 -crf 25 -s 320x224 -aspect 16:9 -r 15 -b 186000 -vb 186000 -minrate 176700 -maxrate 195300 -bt 9300 -bufsize 262500 -muxrate 195300 -vglobal 1 -f rtp rtp://$dstIP:$dstVideoPort1 -vn -acodec libfaac -async 2 -flags +global_header -ac 1 -ar 44100 -ab 64000 -f rtp rtp://$dstIP:$dstAudioPort1 -newaudio -an -vcodec libx264 -coder 0 -threads 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -level 13 -g 20 -crf 25 -s 320x224 -aspect 16:9 -r 20 -b 286000 -vb 286000 -minrate 271700 -maxrate 300300 -bt 14300 -bufsize 367500 -muxrate 300300 -vglobal 1 -f rtp rtp://$dstIP:$dstVideoPort2 -newvideo -vn -acodec libfaac -async 2 -flags +global_header -ac 1 -ar 44100 -ab 64000 -f rtp rtp://$dstIP:$dstAudioPort2 -newaudio -an -vcodec libx264 -coder 0 -threads 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -level 30 -g 25 -crf 25 -s 480x336 -aspect 16:9 -r 25 -b 386000 -vb 386000 -minrate 366700 -maxrate 405300 -bt 19300 -bufsize 472500 -muxrate 405300 -vglobal 1 -f rtp rtp://$dstIP:$dstVideoPort3 -newvideo -vn -acodec libfaac -async 2 -flags +global_header -ac 2 -ar 44100 -ab 64000 -f rtp rtp://$dstIP:$dstAudioPort3 -newaudio -an -vcodec libx264 -coder 0 -threads 0 -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -level 30 -g 25 -crf 25 -s 480x336 -aspect 16:9 -r 25 -b 686000 -vb 686000 -minrate 651700 -maxrate 720300 -bt 34300 -bufsize 787500 -muxrate 720300 -vglobal 1 -f rtp rtp://$dstIP:$dstVideoPort4 -newvideo -vn -acodec libfaac -async 2 -flags +global_header -ac 2 -ar 44100 -ab 64000 -f rtp rtp://$dstIP:$dstAudioPort4 -newaudio Show Sample Output


    0
    ffmpeg -i $src -an -vcodec [...details in description...] rtp rtp://$dstIP:$dstAudioPort4 -newaudio
    theflyingbear · 2011-07-29 15:36:37 4
  • sxga ==> 1280x1024 vga ==> 800x600 ------------------------------------------------ xwininfo -root | grep geometry ------------------------------------------------


    0
    ffmpeg -f alsa -i default -f x11grab -s sxga -r 10 -i :0.0 -f mp4 -s vga -sameq out.mp4
    kev · 2011-09-18 15:10:56 3
  • A simple command to extract audio from flv/mp4 video file. Just change extentions...


    0
    ffmpeg -i video.flv audio.ogg
    aminehmida · 2012-03-05 23:43:45 4
  • 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 !!! ;) Show Sample Output


    0
    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
    dwygo · 2012-08-31 14:48:41 5
  • -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


    0
    ffmpeg -i source.mpg -r 24 -f image2 still-%6d.png
    manuq · 2013-01-10 02:49:15 4
  • -i sets the source file -f and -acodec both set the output to be raw audio, PCM signed 16-bit little endian


    0
    ffmpeg -i source.mpg -f s16le -acodec pcm_s16le audio.raw
    manuq · 2013-01-10 02:54:04 12
  • 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. Show Sample Output


    0
    ffmpeg -i "input.mts" -vcodec copy -acodec pcm_s16le "output.mov"
    lgarron · 2014-01-24 13:00:07 6
  • 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.


    0
    curl 'AudioStream' | ffmpeg -i - -acodec libvorbis file.ogg
    snipertyler · 2014-03-31 02:07:20 7
  • 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.


    0
    youtube-dl -c -o "%(title)s" -f 18 https://www.youtube.com/watch?v=5qSCKUCjdKg
    tg0000 · 2014-06-12 23:31:55 11

  • 0
    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
    xplora1a · 2014-08-23 10:29:15 9
  • 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


    0
    i=in.swf; dump-gnash -1 -j 1280 -k 720 -D "${i%.*}".bgra@12 -A "${i%.*}".wav "${i}"
    mhs · 2015-05-06 23:52:39 27
  • Works on *.mp4 as well. Show Sample Output


    0
    avconv -i vid.avi
    lowrez · 2015-10-16 22:49:52 10
  • to view on another box: nc <server address> <port> | ffplay - use -r to adjust FPS and -q to adjust compression. use on trusted network only as nc is unencrypted.


    0
    ffmpeg -f x11grab -s $(xrandr | awk '/*/ {print $1}') -r 10 -i :0 -an -q 10 -f mjpeg - | nc -lp <port>
    misterhat · 2015-12-21 17:15:30 11
  • Uses ffmpeg to convert all that annoying .FLAC files to MP3 files keeping all the Artist's information in them. There's not much more to it. Show Sample Output


    0
    find . -name "*.flac" -exec ffmpeg -i {} -ab 160k -map_metadata 0 -id3v2_version 3 {}.mp3 \;
    gustavohmsilva · 2016-06-28 19:35:06 10
  • It loops through all files in current directory that have flac extension and converts them to mp3 files with bitrate of 320kpbs using ffmpeg and default codec.


    0
    for FILE in *.flac; do ffmpeg -i "$FILE" -b:a 320k "${FILE[@]/%flac/mp3}"; done;
    Orkan · 2016-07-04 04:13:17 11
  • Replace video and audio extension according to your needs


    0
    ffmpeg -i file.video file.audio
    miskopo · 2016-07-19 08:39:24 13
  • ffmpeg and avconv didnt have this feature. I use this command to hardsubs mkv files to mp4


    0
    mpv file.mkv -o out.mp4
    zodman · 2016-09-09 18:40:01 13
  • I use this command to stream live video to facebook from a vps. you need first convert the file to flv i use mpv to encode with hardsubs a file. and then run ffmpeg to stream the file.


    0
    mpv file.mkv -o out.flv --oac=libmp3lame --oacopts=b=128000; ffmpeg -re -i output-003.flv -f flv 'rtmp://rtmp-api.facebook.com:80/rtmp/facebookkeyandparams'
    zodman · 2016-09-09 18:43:00 17

  • 0
    ffmpeg -i out.mp4 -i logo.png3 -filter_complex "overlay=0:0" -codec:a copy out2.mp4 -y
    zodman · 2016-09-09 21:07:25 16
  • ffprobe doesn't throw an error and was actually made to do exactly that. Usually ffprobe is located in the same folder as ffmpeg. https://ffmpeg.org/ffprobe.html#Description


    0
    ffprobe -i filename.flv
    Yamy · 2016-10-15 20:26:34 17

  • 0
    ffmpeg -start_number 10 -i image-%04d.png -vframes 100 output.webm
    atemvm · 2017-04-05 18:27:29 21
  • Converts an OGG file to MP3 at desired quality, preserving the id3v2 tags.


    0
    ffmpeg -i input.ogg -ab 256k -map_metadata 0:s:0 output.mp3
    woohoo · 2018-08-11 21:44:27 294
  •  < 1 2 3 4 > 

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.

Share Your Commands


Check These Out

pipe commands from a textfile to a telnet-server with netcat
sends commands specified in $commandfile to the telnet-server specified by $telnetserver. to have newlines in $commandfile interpreted as ENTER, save the file in CR+LF (aka "Windows-Textfile") format. if you want to save the output in a separate file, use: $nc $telnetserver 23 < $commandfile > $resultfile

files and directories in the last 1 hour
added alias in ~/.bashrc alias lf='find ./* -ctime -1 | xargs ls -ltr --color'

Generate MD5 of string and output only the hash checksum

Extract ip addresses with sed
Extracts ip addressess from file using sed. Uses a tag(ip) to grep the IP lines after extracting. Must be a way to just output regex matched on sed.

Randomly run command
Randomly decide whether to run a command, or fail. It's useful for testing purposes. . Usage: ran PERCENTAGE COMMAND [ARGS] Note: In this version the percentage is required. . This is like @sesom42 and @snipertyler's commands but in a USABLE form. . e.g. In your complicated shell script, put "ran 99" before a crucial component. Now, it will fail 1% of the time allowing you to test the failure code-path. $ ran 99 my_complex_program arg1 arg2

Ease your directory exploration
Usage : tt [OCCURRENCE] tt will display a tree from your actual path tt .svn will display only line containing .svn

Both view and pipe the file without saving to disk
This is a cool trick to view the contents of the file on /dev/pts/0 (or whatever terminal you're using), and also send the contents of that file to another program by way of an unnamed pipe. All the while, you've not bothered saving any extra data to disk, like you might be tempted to do with sed or grep to filter output.

draw honeycomb
$ tput setaf 1 && tput rev && seq -ws "___|" 81|fold -69|tr "0-9" "_" && tput sgr0 $ $ # (brick wall)

netstat with group by ip adress

Replace spaces in filenames with underscores


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: