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 26
  • 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 267
  •  < 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

Happy Days
AFAIR this is the wording ;)

du command without showing other mounted file systems

Convert seconds to [DD:][HH:]MM:SS
Converts any number of seconds into days, hours, minutes and seconds. sec2dhms() { declare -i SS="$1" D=$(( SS / 86400 )) H=$(( SS % 86400 / 3600 )) M=$(( SS % 3600 / 60 )) S=$(( SS % 60 )) [ "$D" -gt 0 ] && echo -n "${D}:" [ "$H" -gt 0 ] && printf "%02g:" "$H" printf "%02g:%02g\n" "$M" "$S" }

Visit wikileaks.com
Who needs a DNS server

resume other user's screen session via su, without pty error
Normally, if you su to another user from root and try to resume that other user's screen session, you will get an error like "Cannot open your terminal '/dev/pts/0' - please check." This is because the other user doesn't have permission for root's pty. You can get around this by running a "script" session as the new user, before trying to resume the screen session. Note you will have to execute each of the three commands separately, not all on the same line as shown here. Credit: I found this at http://www.hjackson.org/blog/archives/2008/11/29/cannot-open-your-terminal-dev-pts-please-check.

Download SSL server certificate with opsnessl
Useful when we need to create new certificate for site when current one is near expiry. This downloaded cert can be used to provide organisational data directly to new cert. using below command. e.g. openssl x509 -x509toreq -in /tmp/example.com.cert -out example.com.csr -signkey example.com-key.pem

ssh to machine behind shared NAT
Useful to get network access to a machine behind shared IP NAT. Assumes you have an accessible jump host and physical console or drac/ilo/lom etc access to run the command. Run the command on the host behind NAT then ssh connect to your jump host on port 2222. That connection to the jump host will be forwarded to the hidden machine. Note: Some older versions of ssh do not acknowledge the bind address (0.0.0.0 in the example) and will only listen on the loopback address.

Get your external IP address without curl
Curl is not installed by default on many common distros anymore. wget always is :) $ wget -qO- ifconfig.me/ip

Null a file with sudo

power off system in X hours form the current time, here X=2


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: