Convert MP4 to OGV and WebM

Mindwatering Incorporated

Author: Tripp W Black

Created: 02/22/2021 at 11:02 PM



Need to convert existing MP4 (lib264) for standard <video> tag. MP4 doesn't play in Firefox. So multiple formats are needed to get good cross browser and device support.

MP4 - Conversion
- FFMPEG Sample Command:
$ ./ffmpeg -i myvideo.mp4 -c:v libvpx -c:a libvorbis myvideo.webm && ./ffmpeg -i myvideo.mp4 -codec:v libtheora -qscale:v 7 -codec:a libvorbis -qscale:a 5 myvideo.ogv

Embed Video Sample Video Tag:
<div class="videocontainer">
<video class="columnleftpromo" autoplay loop muted playsinline preload="metadata">
<source src="/folder/app.nsf/webIF/Promo1/$File/myvideo.mp4" type="video/mp4">
  <source src="/folder/app.nsf/webIF/Promo1/$File/myvideo.webm" type="video/webm">
<source src="/folder/app.nsf/webIF/Promo1/$File/myvideo.ogv type=video/ogg">

Sample conversion to GIF (if size is small):
$ ./ffmpeg -i myvideo.mp4 -filter_complex 'fps=5,scale=700:-1:flags=lanczos,split [o1] [o2];[o1] palettegen [p]; [o2] fifo [o3];[o3] [p] paletteuse' myvideo.gif

Example to crop video to right middle part of original video. Original size: 1920x800.
$ ./ffmpeg -i myvideotocrop.mp4 -filter:v "crop=700:300:890:380" myvideo.mp4

previous page