Resize mp4 video, convert to ogg and upload to HTML 5 site

Written by
Date: 2013-03-11 16:23:13 00:00

If you want to host your videos by your own instead of having them on youtube, you can use HTML5 standard. Today almost every browser support HTML5 vide tag, therefore there is no more reason to host your videos on Youtube or similar. You can host them by yourself, and if you have enough bandwidth you will not have any problem.

First you need to decrease the size of it, cameras today take HD videos, and those are too big. Resize mp4 videos with just a line.

ffmpeg -i video-input.mp4 -vf scale=iw/2:-1 video-output.mp4

We are using ffmpeg, which is available for Linux and Mac (via brew). That command will resize the video to a half of its original size. The scale=iw/2:-1 is doing that, dividing by 2.

Now, because you need to have two options of the video, one in mp4 for some browsers and one in ogg for others, we will get a copy of the mp4 video in ogg format.

ffmpeg2theora video-output.mp4

We are using ffmpeg2theora, also available for Linux and Mac OS X.

You are now, ready to upload the video to your site and use the <video> tag to show it to your visitors.