Aokocax Useful FFmpeg Commands – Open Source Agenda
The use of video in digital life is increasing exponentially day by day.
I prepared a document explaining how you can easily find answers to video solutions/problems that you will need in daily life with FFmpeg library.
I show you which commands to run for video solutions you will need with about 20 different scenarios in the file. You can forward your questions/questions about the document from the Issues section.
Table of Contents
Convert any video format to other format.
ffmpeg -i source.avi output.mp4
ffmpeg -i source.mov output.mp4
Increasing/decreasing the framerate of the video. (Twitter and some platforms require 30FPS video)
ffmpeg -i source.mp4 -framerate 30 output30fps.mp4
Adding audio to video.
It will be as long as the video or audio, whichever is shorter.
ffmpeg -i source.mp4 -i sound.mp3 -vcodec copy -map 0:v -map 1:a -map 1:a -shortest output.mp4
Cutting the first three seconds of the video.
ffmpeg -i source.mp4 -t 3 output3seconds.mp4
or
ffmpeg -i source.mp4 -t 00:00:03 output3seconds.mp4
Cut a specific range of video.
Getting next 3 seconds starting from 3 seconds
ffmpeg ffmpeg -i source.mp4 -ss 3 -t 3 source3seconds.mp4
Cut video from a specific second to the end of the video
ffmpeg ffmpeg -i source.mp4 -ss 3 output3seconds.mp4
ffmpeg ffmpeg -i source.mp4 -ss 00:00:03 output3seconds.mp4
Convert video to animated gif.
ffmpeg -i source.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 output.gif
Converting part of video to animated gif.
ffmpeg -i source.mp4 -ss 1 -t2 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 tar.gif
Concat two videos (without audio).
ffmpeg -i source1.mp4 -i source2.mp4 -y -filter_complex "[0:v][1:v] concat=n=2:v=1:[v]" -map "[v]" output.mp4
Concat two videos back-to-back (with audio).
ffmpeg -i source1.mp4 -i source2.mp4 -y -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0] concat=n=2:v=1:a=1 [v] [a]" -map "[a]" -map "[v]" output.mp4
Adding a watermark to the middle of the screen.
ffmpeg.exe -i source.mp4 -i logo.png -filter_complex "overlay = (main_w - overlay_w)/2:(main_h - overlay_h) / 2" watermark.mp4
Adding a watermark to a specific point of the screen.
ffmpeg -i source.mp4 -i logo.png -filter_complex "overlay = (main_w - overlay_w)/2:(main_h - overlay_h) / 2" watermark.mp4
ffmpeg -i source.mp4 "%04d.png"
Take a screenshot of a specific frame in the video.
ffmpeg -i wm.mp4 -ss 00:00:01.23 -vframes 1 -q:v 2 output.jpg
Take a screenshot from every 1 second of the video
ffmpeg.exe -i wm.mp4 -r 1 -f image2 screenshot-%03d.jpg
Merging two separate audio files.
ffmpeg -i sound1.wav -i sound2.wav -filter_complex "[0:0][1:0]concat=n=2:v=0:a=1[out]" -map "[out]" soundconcat.wav
ffmpeg -i source.mp4 output.mp3
To mute the video.
ffmpeg -i source.mp4 -c copy -an sessiz.mp4
Making video from photo gallery.
ffmpeg -f concat -i filelist.txt -i audio.mp3 -c:a copy output.mp4
filelist.txt sample file
a1.jpg a2.jpg a3.jpg
Writing text on the video with the desired font.
ffmpeg -i source.mp4 -filter:v "drawtext=enable="between(t,0,2)":fontsize=30:fontfile=font.otf:fontcolor=yellow:text="my text":x = (w - text_w) / 2:y = (h - text_h - line_h) / 2" output.mp4
between(t,0,2) 0-2 seconds
center the screen x = (w – text_w) / 2:y = (h – text_h – line_h) / 2
You can make it output in the position you want by giving x and y values.
Read more here: Source link