Example of complete command : ffmpeg -hide_banner -i `ls -rth *mkv | tail -1` -ss 1 -t 5 -filter_complex "[0:v] fps=12,crop=1600:1024:0:0,split [a][b];[a] palettegen [p];[b][p] paletteuse" -y ok.gif; gwenview ok.gif

From personal use

  • merge video/audio ffmpeg -i video.mp4 -i audio.mp4a -c:v copy -c:copy output.mp4
  • desktop streaming ffmpeg -framerate 25 -f x11grab -i :1 -re -f lavfi -i anullsrc -f flv rtmp://video.benetou.fr:1935/live/APIKEY
  • generate timelapse montage from video for i in {0..9}; do ffmpeg -ss $(expr $i \* $( expr $(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 fosdem_metaverse.mp4 | sed "s/\..*//") / 10 )) -i fosdem_metaverse.mp4 -vframes 1 -s 480x300 -f image2 imagefile$i.jpg; done && montage -tile 10x1 -geometry 480x300+0+0 imagefile*jpg mosaic.jpg
  • generate video from images ffmpeg -framerate 30 -i %d.png -y output.mp4
    • renumbering I=0; for F in $(ls -1 *png); do let I++; cp $F res/$I.png; done; cd res
  • some WebCams, e.g Logitech C270, are not recognized as photocamera and only provide a stream
    • use ffmpeg to capture a frame then e.g rm out.jpg; ffmpeg -f v4l2 -video_size 544x288 -i /dev/video1 -frames 1 out.jpg
  • overlay image to virtual webcam ffmpeg -i /dev/video0 -i new.svg -filter_complex "[1]hflip[f],[0][f]overlay=format=auto,format=yuv420p[v]" -map "[v]" -f v4l2 /dev/video2 -nostdin -hide_banner -nostats &
    • use sudo modprobe v4l2loopback to get /dev/video2
  • screen capture without OBS ffmpeg -framerate 25 -f x11grab -i :1 output.mp4 (but no audio)
  • webcam live streaming to PeerTube instance ffmpeg -f v4l2 -i /dev/video0 -re -f lavfi -i anullsrc -f flv rtmp://video.benetou.fr:1935/live/APIKEY
  • timelapse screen capture to video -framerate 24 -i img%03d.png -vf scale=720:-2 -y output.mp4
  • -re -loop 1 -i video_test_mire.jpg -vcodec libx264 -f flv rtmp://live.twitch.tv/app/`cat ~/.twitch_key` to stream an image (or video, or playlist) to an RTMP platform, e.g. Twitch
  • -filter:v "[in] crop=450:500:0:0 [crop]; [crop] lenscorrection=k2=0.1:k1=-0.4" to chain filters
  • -f x11grab -s 2560x1440 -i :1 for screen capturing on specified resolution and screen
  • add text -vf drawtext="text='Complimenti':"
  • -b:v 2600k to change video bitrate
  • -hide_banner to remove configuration build options
  • -filter:v "setpts=0.5*PTS" to double speed (halving the presentation timestamp of a frame)
  • using pause (to bring to the background) then fg to bring the process back to life and continue encoding
  • resolution
    • fixed: -vf scale=2048:1024
    • relative e.g. half: -vf scale=iw*.5:ih*.5
  • crop: -filter:v "crop=720:420:0:450" following the format "crop=out_w:out_h:x:y"
  • start and duration: -ss 5 -t 25, especially important to test without wasting time
    • -to 1:25 to use the ending time
    • note the -ss 0:1:59 format (to avoid using bc to calculate starting time)
  • remove audio: -an
  • remove video: ffmpeg -i input-video.mkv -vn -acodec copy opus
  • -y to confirm e.g. to replace existing file

To explore


Note

My notes on Tools gather what I know or want to know. Consequently they are not and will never be complete references. For this, official manuals and online communities provide much better answers.