Skip to content

Instantly share code, notes, and snippets.

@JoelLisenby
Last active September 6, 2019 16:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoelLisenby/a3bb5b60c400283c286550e6c3bdd407 to your computer and use it in GitHub Desktop.
Save JoelLisenby/a3bb5b60c400283c286550e6c3bdd407 to your computer and use it in GitHub Desktop.
ffmpeg video encoding for web (chrome, firefox, safari, etc)
# h265
ffmpeg -i input.mp4 -c:v libx265 -vf scale=1280:720 -pix_fmt yuv420p output.mp4
# h265 with colorspace specified
ffmpeg -i input.mp4 -c:v libx265 -vf scale=1280:720 -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 output.mp4
# h265 with colorspace specified and no audio
ffmpeg -i input.mp4 -c:v libx265 -vf scale=1280:720 -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -an output.mp4
# webm
ffmpeg -i input.mp4 -c:v libvpx-vp9 -vf scale=1280:720 -pix_fmt yuv420p -minrate 5M -b:v 1M output.webm
# webm with colorspace specified
ffmpeg -i input.mp4 -c:v libvpx-vp9 -vf scale=1280:720 -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -minrate 5M -b:v 1M output.webm
# webm with colorspace specified and bitrate limited to 2000k / crf 30 and no audio
ffmpeg -i input.mp4 -c:v libvpx-vp9 -vf scale=1280:720 -pix_fmt yuv420p -color_primaries bt709 -color_trc bt709 -colorspace bt709 -crf 30 -b:v 2000k -an output.webm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment