Skip to content

Instantly share code, notes, and snippets.

@YuanLiou
Created June 30, 2023 09:45
Show Gist options
  • Save YuanLiou/569eae916ea38ab99738beae20b06cc0 to your computer and use it in GitHub Desktop.
Save YuanLiou/569eae916ea38ab99738beae20b06cc0 to your computer and use it in GitHub Desktop.
mmpeg fish shell
# Optimize mp4
# Usage: optimizeVideo video_file
function optimizeVideo
set video_file $argv[1]
ffmpeg -i "$video_file" -vcodec h264 -acodec mp2 "$video_file.mp4"
end
# Convert video to gif file.
# Usage: video2gif video_file
function video2gif
set video_file $argv[1]
set scale 320
set fps 10
ffmpeg -y -i "$video_file" -vf fps=$fps,scale=$scale:-1:flags=lanczos,palettegen "$video_file.png"
ffmpeg -i "$video_file" -i "$video_file.png" -filter_complex "fps=$fps,scale=$scale:-1:flags=lanczos[x];[x][1:v]paletteuse" "$video_file.gif"
rm "$video_file.png"
end
# endregion Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment