book
  • README
  • cheatsheet
    • bash
      • builtin
      • syntactic sugar
      • cmd
      • havefun
    • text-processing
      • awk
      • sed
      • html
      • json
      • regex
      • unicode
    • osx
    • curl
    • tricky
    • widget
    • proxy
    • colors
    • math
    • media
    • ssl
      • keystore
      • verification
      • server
      • client
      • tricky
    • windows
      • powershell
      • choco
      • wsl
      • wt
      • shortcut
      • clsid
      • env
      • shell:folder
  • vim
    • nvim
    • install
    • color
    • plugins
      • usage
      • other plugins
      • deprecated
    • tricky
    • viml
    • windows
    • troubleshooting
  • devops
    • admin tools
    • ssh
    • git
      • config
      • alias
      • submodule
      • eol
      • example
      • gerrit
        • gerrit API
      • github
      • troubleshooting
      • tricky
      • statistics
    • pre-commit
    • release-tools
    • tmux
      • cheatsheet
    • ansible
    • vault
    • artifactory
      • api
      • cli
      • aql
      • nginx cert
    • klocwork
      • kwadmin
      • kwserver
      • api
      • q&a
    • elk
    • mongodb
    • android
    • mobile
  • jenkins
    • config
      • windows
    • appearance
    • troubleshooting
    • jenkinsfile
      • utility
      • parallel
      • build
      • envvar
      • properties
      • trigger
      • node
    • script
      • job
      • build
      • stage
      • agent
      • security & authorization
      • exception
      • monitor
      • tricky
    • api
      • blueocean
    • cli
    • plugins
      • kubernetes
      • docker
      • shared-libs
      • lockable-resource
      • ansicolor
      • badge
      • groovy-postbuild
      • simple-theme
      • customizable-header
      • artifactory
      • jira-steps
      • job-dsl
      • build-timeline
      • crumbIssuer
      • coverage
      • uno-choice
      • tricky
  • virtualization
    • kubernetes
      • init
        • kubespray
        • kubeadm
          • environment
          • crio v1.30.4
          • docker v1.15.3
          • HA
        • addons
        • etcd
      • kubectl
        • pod
        • deploy
        • replicasets
        • namespace
        • secrets
      • node
      • certificates
      • events
      • kubeconfig
      • kubelet
      • troubleshooting
      • cheatsheet
      • auth
      • api
      • tools
        • monitor
        • helm
        • network
        • minikube
    • docker
      • run & exec
      • voume
      • remove
      • show info
      • dockerfile
      • dockerd
      • tricky
      • troubleshooting
      • windows
    • crio
    • podman
  • ai
    • prompt
  • osx
    • apps
      • init
      • brew
    • defaults
    • system
    • network
    • script
    • tricky
  • linux
    • devenv
    • util
      • time & date
      • output formatting
      • params
      • tricky
    • nutshell
    • disk
    • network
    • troubleshooting
    • system
      • apt/yum/snap
      • authorization
      • apps
      • x11
    • ubuntu
      • systemctl
      • x
    • rpi
  • programming
    • groovy
    • python
      • config
      • basic
      • list
      • pip
      • q&a
    • others
    • archive
      • angular
      • maven
      • mysql
        • installation
        • logs
      • ruby
        • rubyInstallationQ&A
  • tools
    • fonts
    • html & css
    • Jira & Confluence
    • node & npm
      • gitbook
      • hexo
      • github.page
      • code themes
    • app
      • microsoft office
      • vscode
      • virtualbox
      • iterm2
      • browser
      • skype
      • teamviewer
      • others
  • quotes
  • english
Powered by GitBook
On this page
  • highly recommanded
  • video
  • image
  • animation flow chart
  • others

Was this helpful?

  1. cheatsheet

media

PreviousmathNextssl

Last updated 1 month ago

Was this helpful?

highly recommanded

video

get audio from video

[!NOTE|label:references:]

  • ffmpeg params:

    • -acodec copy -vn

    • -ab 12800 -ar 44100

$ ffmpeg -i source.mpg -f s16le -acodec pcm_s16le audio.raw

# https://www.commandlinefu.com/commands/view/52/rip-audio-from-a-video-file.
$ mplayer -ao pcm -vo null -vc dummy -dumpaudio -dumpfile <output.file> <input.file>

# or
$ ffmpeg -i file.video file.audio

download video

  • $ yt-dlp --external-downloader ffmpeg --external-downloader-args "-ss 00:05:00 -t 00:01:00" "https://www.youtube.com/watch?v=Y6DGABIcB3w"
  • $ youtube-dl -t --extract-audio --audio-format mp3 YOUTUBE_URL_HERE

convert flv to mp4

$ ffmpeg -i name.flv -qscale 0 name.mp4

options:

  • pic-%02d.png: Read all images from the current folder with the prefix pic-, a following number of 2 digits (%02d) and an ending of .png

  • -r 1/5 : Displays each image for 5 seconds

  • r 30 : Output framerate of 30 fps.

  • -c:v libx264 : Output video codec: h264

  • pix_fmt yuv420p : YUV pixel format

$ ffmpeg -r 1/5 -i pic-%02d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
$ ffmpeg -i out.mp4 -vf scale=-1:720 out_720p.mp4

convert to 5 mins (300 sec)

$ ffmpeg -i name.mp4 -ss 0 -t 300 name-5m.mp4

sequence convert (every 5 mins ~> 300 secs)

  • first 5 mins (0 ~> 300)

    $ ffmpeg -i name.mp4 -ss 0 -t 300 name-5m-1.mp4
  • second 5 mins (300*1 ~> 300)

    $ ffmpeg -i name.mp4 -ss 300 -t 300 name-5m-2.mp4
  • third 5 mins (300*2 ~> 300)

    $ ffmpeg -i name.mp4 -ss 600 -t 300 name-5m-3.mp4
  • -density 400 : Set the horizontal resolution of the image

$ convert -density 400 input.pdf pic.png

combine video and audio

$ ffmpeg -i <origin-video> -i <origin-audio> -c copy -map 0:0 -map 1:0 -shortest <new-video>

compression mov

[!NOTE|label:references:]

$ ffmpeg -i coc-groovy-lsp.org.mov -c:v libx264 -c:a copy -crf 20 coc-groovy-lsp.mov
$ ls -altrh | grep coc-groovy-lsp
-rw-r--r--   1 marslo staff  37M Jan 15 18:39 coc-groovy-lsp.org.mov
-rw-r--r--   1 marslo staff  10M Jan 15 19:02 coc-groovy-lsp.mov

$ ffmpeg -i coc-groovy-lsp-minirc.org.mov -c:v libx264 -c:a copy -crf 20 coc-groovy-lsp-minirc.mov
$ ls -altrh | grep coc-groovy-lsp-minirc
-rw-r--r--   1 marslo staff  14M Jan 15 19:16 coc-groovy-lsp-minirc.org.mov
-rw-r--r--   1 marslo staff 4.1M Jan 15 19:20 coc-groovy-lsp-minirc.mov

convert mov to mp4

[!NOTE|label:reference:]

# handbrakecli
$ handbrakecli -i {in-video}.mov -e x264 -E facc -o {out-video}.mp4

# ffmpeg
$ ffmpeg -i {in-video}.mov -vcodec h264 -acodec aac {out-video}.mp4
# or
$ ffmpeg -i input.mov -c copy -movflags +faststart output.mp4

slice video to images

$ ffmpeg -i video.mp4 -vf "fps=24" css_%04d.png

convert video to gif

[!NOTE|label:references:]

    • options:

      • -ss 30: skip first 30 seconds

      • -t 3: create a 3 second output

        • scale=0:-1: do not resize

    • ffmpeg options:

      • -c:v pam: chooses the pam image encoder

      • -f image2pipe: chooses the image2pipe muxer

    • convert options:

      • -loop 0: makes infinite loop

      • -layers optimize: enable the general purpose GIF optimizer

    • to set rgb-vf scale=320:-1,format=rgb8,format=rgb24

# with specific size
$ ffmpeg -ss 30 -t 3 -i input.mp4 \
         -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" \
         -loop 0 output.gif

# or
$ ffmpeg -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos" -c:v pam \
         -f image2pipe - | \
         convert -delay 10 - -loop 0 -layers optimize output.gif

# with original size
$ ffmpeg -ss 30 -t 3 -i coc-groovy-minirc.org.mov \
         -vf "fps=35" \
         -loop 0 output.gif

# using ImageMagick
$ convert in.mp4 out.gif
  • #### video2gif.sh
    # Convert video to gif file.
    # Usage: video2gif video_file (scale) (fps)
    video2gif() {
      ffmpeg -y -i "${1}" -vf fps=${3:-10},scale=${2:-320}:-1:flags=lanczos,palettegen "${1}.png"
      ffmpeg -i "${1}" -i "${1}.png" -filter_complex "fps=${3:-10},scale=${2:-320}:-1:flags=lanczos[x];[x][1:v]paletteuse" "${1}".gif
      rm "${1}.png"
    }
    
    REM video2gif.bat
    @echo off
    set arg1=%1
    set arg2=%arg1:~0,-4%
    ffmpeg -y -i %arg1% -vf fps=10,scale=-1:-1:flags=lanczos,palettegen %TEMP%\palette.png
    ffmpeg -i %arg1% -i %TEMP%\palette.png -filter_complex "fps=10,scale=-1:-1:flags=lanczos[x];[x][1:v]paletteuse" %arg2%.gif
    del /f %TEMP%\palette.png
    
    # usage
    $ video2gif input.flv
    $ video2gif input.flv 320 10
  • src="input.flv"
    dest="output.gif"
    palette="/tmp/palette.png"
    
    ffmpeg -i $src -vf palettegen -y $palette
    ffmpeg -i $src -i $palette -lavfi paletteuse -y $dest
  • $ url=http://www.youtube.com/watch?v=V5bYDhZBFLA;
    youtube-dl -b $url; mplayer $(ls ${url##*=}*| tail -n1) -ss 00:57 -endpos 10 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound

convert pngs into gif

$ convert -delay 5 -loop 0 -dither None -colors 80 "frames/ffout*.png" -fuzz "40%" -layers OptimizeFrame  "output.gif"

# simple version
$ convert -delay 10 *.png sample.gif
$ ffmpeg -f x11grab -r 25 -s 800x600 -i :0.0 /tmp/outputFile.mpg

# or: https://www.commandlinefu.com/commands/view/7109/capture-video-of-a-linux-desktop
$ ffmpeg -y -f alsa -ac 2 -i pulse -f x11grab -r 30 -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -i :0.0 -acodec pcm_s16le output.wav -an -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.mp4

# or: https://www.commandlinefu.com/commands/view/5189/capture-video-of-a-linux-desktop
$ ffmpeg -f x11grab -s `xdpyinfo | grep 'dimensions:'|awk '{print $2}'` -r 25 -i :0.0 -sameq /tmp/out.mpg > /root/howto/capture_screen_video_ffmpeg

# or: https://www.commandlinefu.com/commands/view/24389/capture-video-of-a-linux-desktop
$ ffmpeg -video_size 1024x768 -framerate 25 -f x11grab -i :0.0+100,200 output.mp4

# or: https://www.commandlinefu.com/commands/view/12572/capture-video-of-a-linux-desktop
ffmpeg -f x11grab -s wxga -r 25 -i :0.0+1366,0 -qscale 0 /tmp/out.mpg

tips

  • $ find -type f -name "*.avi" -print0 | xargs -0 mplayer -vo dummy -ao dummy -identify 2>/dev/null | perl -nle '/ID_LENGTH=([0-9\.]+)/ && ($t +=$1) && printf "%02d:%02d:%02d\n",$t/3600,$t/60%60,$t%60' | tail -n 1
  • $ mencoder -ss <start point> -endpos <time from start point> -oac copy -ovc copy <invid> -o <outvid>
    
    # i.e.: take frames starting at 15.2 seconds for a total of 45.9 seconds
    $ mencoder -ss 15.2 -endpos 30.7 -oac copy -ovc copy origin.avi -o new.avi
    
    # i.e.: total 3m3s length
    $ mencoder -ss 1 minute -endpos 2 minutes 3 seconds -oac copy -ovc copy origin.avi -o new.avi
  • $ nc HOST PORT | tee movie.mp4 | mplayer -
    
    # via ssh: https://www.commandlinefu.com/commands/view/12955/securely-stream-and-save-a-file-from-a-remote-server
    $ ssh USER@HOST cat REMOTE_FILE.mp4 | tee LOCAL_FILE.mp4 | mplayer -

image

$ ffmpeg -i file.webp out.png
  • for multiple images

    $ for x in ls *.webp; do
        ffmpeg -i "$x" "${x%.webp}.jpg"
      done

identity an image

$ identify arms009.jpg | grep -o "[[:digit:]]*x[[:digit:]]*" | tail -1
1024x768

convert svg to png

references:

  • $ brew install librsvg
    $ rsvg-convert -h 256 file.svg > file.png
  • $ qlmanage -t -s 1000 -o . k-1.svg
  • convert

    $ convert -background none \           # transparent background
              -density 300 \               # DPI (dots per inch) to 300, default is 72
              -filter Lanczos \            # lanczos provides high-quality resampling
              -resize 400x \               # width of 400 pixels x height is auto-calculated
              -antialias \                 # antialiasing
              input.svg output.png
    
    $ convert -resize 128x128 input.svg output.png
    
    # or
    $ convert -density 500 -resize 128x128 input.svg output.png
    $ convert -density 1200 -resize 10000x10000 your.svg your.png
    $ convert -background none -size 1024x1024 infile.svg outfile.png
  • $ npm install svgexport -g
    $ svgexport input.svg output.png 256:256
  • [!NOTE]

    • Warning: Option --without-gui= is deprecated

    $ brew install inkscape
    $ inkscape --shell -w 256 -h 256 code.svg -o code.png -background none
    
    # or
    $ inkscape -z -w 1024 -h 1024 input.svg -e output.png
  • in_size=50
    in_density=96
    out_size=512
    
    magick -density "%[fx:$in_density*$out_size/$in_size]" button.svg button3.png

convert HEIC/HEIF to PNG

$ brew install imagemagick --with-libheif

# for single convert
$ magick convert [-monitor] <name>.HEIC <new-name>.png

# for batch convert
$ magick mogrify [-monitor] -format png *.HEIC.
#!/usr/bin/env sh

COLOR=yellow
sed -i -E 's/fill\="[^"]+"//g; s/stroke\="[^"]+"//g' *.svg
sed -i "s/<path/<path fill=\"$COLOR\" stroke=\"$COLOR\"/g" *.svg
  • or

    #!/usr/bin/env sh
    COLOR=yellow
    sed -i -E 's/fill\="[^"]+"//g; s/stroke\="[^"]+"//g' *.svg
    sed -i "s/<path/<path fill=\"$COLOR\" stroke=\"$COLOR\"/g" *.svg
    sed -i "s/<rect/<rect fill=\"$COLOR\" stroke=\"$COLOR\"/g" *.svg
    sed -i "s/<polygon/<polygon fill=\"$COLOR\" stroke=\"$COLOR\"/g" *.svg
    sed -i "s/<circle/<circle fill=\"$COLOR\" stroke=\"$COLOR\"/g" *.svg
    sed -i "s/<ellipse/<ellipse fill=\"$COLOR\" stroke=\"$COLOR\"/g" *.svg
    sed -i "s/<polyline/<polyline fill=\"$COLOR\" stroke=\"$COLOR\"/g" *.svg
    sed -i -E "s/stroke\:[^\;]+/stroke\:$COLOR/g" *.svg
    sed -i -E "s/fill\:\#[0-9]+/fill\:$COLOR/g" *.svg

animation flow chart

create animation flow

[!NOTE|label:references:]

  • export to svg

convert svg to gif

  • online tools

    [!NOTE|label:references:]

      • increase the SVG image height to make the watermark shows below of original image

  • local tools

others

$ man -t manpage | ps2pdf - filename.pdf

# https://www.commandlinefu.com/commands/view/9751/save-man-page-as-pdf
$ man -t awk | ps2pdf - awk.pdf
$ ifconfig | convert label:@- ip.png
# or: https://www.commandlinefu.com/commands/view/18168/save-command-output-to-image
$ convert label:"$(ifconfig)" output.png

# and more
$ ifconfig | convert -background none label:@- miff:- | composite -tile pattern:checkerboard - -compose Dst_Over ip.png

# and more with fonts: `convert -list font | grep Font:`
$ /usr/bin/lynx -dump -nolist http://www.commandlinefu.com/ | /usr/bin/convert -font "FreeMono-Medium" label:@- output.png

fps=10: filter sets the frame rate

scale=320:-1: resize the output to 320 pixels wide and automatically determine the height, the is used in this example.

split[s0][s1]: filter will allow everything to be done in one command and avoids having to create a temporary PNG file of the palette

[s0]palettegen[p];[s1][p]paletteuse: and filters will generate and use a custom palette generated from your input

-vf "fps=10,scale=320:-1:flags=lanczos" a using the and filters.

-delay: set frame rate with a combination of the filter in ffmpeg

convert svg to gif with watermark in

crop the watermark in

chrome extension:

desktop application: : .045s, 0.50s or 0.52s

cmd.to
download video and extract with sepcific time
convert youtube video to mp3
convert png to mp4
scale the media
convert pdf to png
Reduce MOV file size
convert .mov video to .mp4 with ffmpeg
How do I convert a video to GIF using ffmpeg, with reasonable quality?
fps
lanczos scaling algorithm
split
palettegen
paletteuse
filtergraph
fps
scale
fps
ImageMagick Examples -- Animation Optimization
thevangelist/FFMPEG-gif-script-for-bash
function
another simple solution
create an animated gif from a youtube video
record a screencast and convert to mpeg
get the total length of time
edit video by cutting the part you like without transcoding
stream and copy a video from lan
convert webp to png
Command-line application for converting SVG to PNG on Mac OS X
"Bake" an SVG image into a PNG at a given resolution? [closed]
Converting large SVG to PNG file
tomkwok/svgasm
rsvg-convert
qlmanage
svgexport
inkscape
imagemagick
sed command to batch change fill and stroke of an SVG
#3739 - Export as a GIF
如何用drawio让自己的流程图线条产生动起来的效果
processflow.sharehoo.cn
draw.io
Convert animated SVG to GIF free
html5animationtogif.com
animated GIF editor and Gif maker
Chrome Capture - screenshot & GIF
GIF Brewery
GIF Brewery for Mac v3.9.5 英文破解 GIF制作工具
提取码: iasr
Gifox
create manpage pdf
save command output to image
highly recommanded
video
get audio from video
download video
convert flv to mp4
convert png to mp4
scale the media
combine video and audio
compression mov
convert mov to mp4
slice video to images
convert video to gif
convert pngs into gif
record a screencast and convert to mpeg
tips
image
convert webp to png
identity an image
convert svg to png
convert HEIC/HEIF to PNG
sed command to batch change fill and stroke of an SVG
animation flow chart
create animation flow
convert svg to gif
others
create manpage pdf
save command output to image
combine
magick
flow animation
export to svg
without increase height
increase height
crop gif