..
List of Useful FFmpeg Commands
Table of Contents
Generate gif from video
ffmpeg -i video.mp4 -vf "crop=in_w-200:in_h-200,fps=30,scale=640:-1:flags=lanczos" -c:v gif your_gif.gif -y
Generate gif with watermark from raw gif
ffmpeg -i your_gif.gif -vf "drawtext=text='©Tiago Aguiar':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=24:fontcolor=white" -c:v gif gif_watermark.gif -y
Generate video from gif with subtitle
ffmpeg -i video.mp4 -vf "crop=in_w-200:in_h-200,drawtext=text='©Tiago Aguiar':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=34:fontcolor=white,subtitles=subtitle.srt" -codec:a copy your_video_watermark.mp4
subtitle.srt
example:
1 00:00:00,000 --> 00:00:10,000 Leia a legenda
Compress Video
ffmpeg -i <input_file> -vcodec libx265 -crf 28 <dest_file>
Change Video Frame Rate
SOURCE=$1 DEST=$2 FRAME_RATE=`echo | awk "{print 1.0/$3}"` echo $FRAME_RATE ffmpeg -i $SOURCE -filter_complex "[0:v]setpts=$FRAME_RATE*PTS[v];[0:a]atempo=$3[a]" -map "[v]" -map "[a]" $DEST # example # frame_rate tetris-shorts.mp4 tetris-shorts-render.mp4 1.1
video to gif
ffmpeg -i gen.mp4 -vf "fps=30,scale=1280:-1:flags=lanczos" -c:v gif seu_gif.gif
with crop
ffmpeg -i gen.mp4 -vf "crop=in_w-200:in_h-200,fps=30,scale=1280:-1:flags=lanczos" -c:v gif seu_gif.gif -y
gif watermark
ffmpeg -i seu_gif.gif -vf "drawtext=text='©Tiago Aguiar':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=34:fontcolor=white" -c:v gif gif_com_marca_dagua.gif -y
subtitle
1 00:00:00,000 --> 00:00:10,000 Linha 1 Linha 2
video w/ watermark
ffmpeg -i gen.mp4 -vf "crop=in_w-200:in_h-200,drawtext=text='©Tiago Aguiar':x=(w-text_w)/2:y=(h-text_h)/2:fontsize=34:fontcolor=white,subtitles=legenda.srt" -codec:a copy seu_video_com_marca_dagua.mp4