convert mp4 to webm and ogv
I wanted to share an .mp4 file on my webserver but Firefox didn’t play it. It turned out Firefox prefers the .webm and .ogv formats, while Chrome can play .mp4.
Convert mp4 then:
.mp4 to .webm
ffmpeg -i input.mp4 -vcodec libvpx -acodec libvorbis -b:v 600k -cpu-used 4 -threads 8 output.webm
To change the quality, play with the “600k” value (bitrate).
.mp4 to .ogv
ffmpeg -i final.mp4 -vcodec libtheora -acodec libvorbis -b:v 600k -cpu-used 4 -threads 8 final.ogv
Here the difference is the codec (libtheora instead of libvpx).
Maybe I missed something, but the .webm file seemed to me to have better quality than .ogv. So I think it’s enough to support two formats only: .mp4 for Chrome and .webm for Firefox. By the way, in my test the input file (.mp4) had the best quality and smallest filesize, but again, I may miss something.
And here is an HTML5 code that can play your video:
<video controls preload="metadata" width="1024" height="768" poster="images/front.jpg"> <source src="video.mp4" type="video/mp4"> <source src="video.webm" type="video/webm"> <p>Please use a modern browser to view this video.</p> </video>