Skip to content

Instantly share code, notes, and snippets.

@ludndev
Created January 10, 2025 17:10
Show Gist options
  • Save ludndev/8299c15f5f316fc07fada16e86cc95f7 to your computer and use it in GitHub Desktop.
Save ludndev/8299c15f5f316fc07fada16e86cc95f7 to your computer and use it in GitHub Desktop.

get cover from video

ffmpeg -i SampleVideo_1280x720_30mb.mp4 -ss 00:00:01.000 -vframes 1 exports/cover.png

each 10 seconds

ffmpeg -i SampleVideo_1280x720_30mb.mp4 -vf fps=10/60 exports/thumbnails/thumbnail-%03d.jpg

convert to lower resolution if possible: 1080p, 720p, 480p, 360p

ffmpeg -i SampleVideo_1280x720_30mb.mp4 -vf scale=1080:1080 -c:v libx264 -crf 23 -preset veryslow -c:a aac -strict experimental -b:a 128k -movflags +faststart -y exports/video_1080p.mp4
ffmpeg -i SampleVideo_1280x720_30mb.mp4 -vf scale=720:720 -c:v libx264 -crf 23 -preset veryslow -c:a aac -strict experimental -b:a 128k -movflags +faststart -y exports/video_720p.mp4
ffmpeg -i SampleVideo_1280x720_30mb.mp4 -vf scale=480:480 -c:v libx264 -crf 23 -preset veryslow -c:a aac -strict experimental -b:a 128k -movflags +faststart -y exports/video_480p.mp4    
ffmpeg -i SampleVideo_1280x720_30mb.mp4 -vf scale=360:360 -c:v libx264 -crf 23 -preset veryslow -c:a aac -strict experimental -b:a 128k -movflags +faststart -y exports/video_360p.mp4

visually lossless

ffmpeg -i SampleVideo_1280x720_30mb.mp4 -vf scale=480:480 -c:v libx264 -crf 18 -preset veryslow -c:a copy exports/video_lossless_480p.mp4
ffmpeg -i SampleVideo_1280x720_30mb.mp4 -vf scale=360:360 -c:v libx264 -crf 18 -preset veryslow -c:a copy exports/video_lossless_360p.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment