Skip to content

Instantly share code, notes, and snippets.

@jnettome
Last active August 30, 2019 15:18
Show Gist options
  • Save jnettome/12f8a484ec9f789f0b98d74f20e0d5b6 to your computer and use it in GitHub Desktop.
Save jnettome/12f8a484ec9f789f0b98d74f20e0d5b6 to your computer and use it in GitHub Desktop.
ffmpeg mp4 and webm for web

ffmpeg mp4 and webm for web

install ffmpeg https://gist.github.com/clayton/6196167

no audio

ffmpeg -i demo-player.mov -f webm -vcodec libvpx-vp9 -vb 1024k -an demo-player.webm

ffmpeg -i demo-player.mov -f mp4 -vcodec libx264 -vb 1024k -an -preset slow demo-player.mp4

generate thumbnail

ffmpeg -i input-file.mp4 -ss 00:00:01.000 -vframes 1 output.png

for f in *.mp4; do ffmpeg -i "$f" -ss 00:00:03 -vframes 1 -s 480x320 "${f%.mp4}.jpg"; done

embed it

<video autoplay muted loop poster="/demoplayer.jpg">
  <source
    src="my-new-video.webm"
    type="video/webm">
  <source
    src="my-new-video.mp4"
    type="video/mp4">
</video>

reference

https://jshakespeare.com/encoding-browser-friendly-video-files-with-ffmpeg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment