Skip to content

3GP to WebM encoding

Yesterday I blogged about jumping off the Atomium. In that post, I included a video for you to see, using the relatively new WebM video standard. It took me five hours of piss-farting around to get that video on there.

To save myself some frustration in the future, I thought I'd take some (more) time to note down the eventual combination used to re-encode the video. Maybe it will be useful to you too.

I don't have a Linux box available at the moment, so MEncoder was out of the question (it's crap under Windows). All of this was done under Windows with free software.

To start with, the video was recorded with a Nexus One, so the file itself was in 3GP format (essentially MP4). However, it was filmed in portrait mode, so it needed to be rotated as the phone didn't do this automatically. I also wanted to watermark the video, and cut the video down to a smaller length, so the easiest way to do this is by using the tried and tested VirtualDub.

However, VirtualDub doesn't support the 3GP (or MP4) container, so I needed to get this into an AVI format without it being recompressed. To do this conversion, I used Avidemux, which despite the backwards name does actually let you de-multiplex 3GP/MP4 files and re-multiplex them into an AVI. You can do this keeping the original codecs in place — since you're only changing the container there is no loss from the original source.

VirtualDub requires VfW codecs to read files, so I needed to get an x264 driver, but also one that was 64-bit. I ended up using x264vfw which worked flawlessly.

Once an AVI file was generated, this could be loaded into VirtualDub. I kept the audio stream as it was, and processed the video stream with three filters: one to rotate the image, and two logo filters to apply the URL and caricature (if you remember that) overlays, both set with 50% transparency. These two files are TARGA files because I couldn't get VirtualDub to accept PNG files with alpha channel transparency.

To avoid video loss, I set the video codec for the output from VirtualDub to be uncompressed RGB/YCbCr, and dumped everything out to a new AVI file.

The WebM format is essentially MKV with rules defining the video codec (VP8) and the audio codec (Vorbis), so if you can find an encoder that can transcode to VP8/Vorbis and encapsulate in MKV, you can tweak the settings to create a compliant WebM file. In the end I didn't need to bother, as I used XMedia Recode with the WebM profile to encode the video.

That's not quite it yet, though. The blog isn't HTML5 yet, and I still haven't finished rewriting the software yet, so at the moment the code looks like this (the HTML5 video tag has been commented out intentionally):

<!-- <video width="480" height="720" controls="controls" src="Video.webm"> -->
  <object data="Video.webm" type="video/webm" width="480" height="720">
   <p><a href="Video.webm">Click here to see the video</a>.</p>
  </object>
<!-- </video> -->

Here I'm using the object tag for backwards compatibility. It kind of works. Sort of. Not really. Whatever.

Apache also needed the following line to be added to the configuration in order to output the correct MIME type:

AddType video/webm .webm

It'll be easier in the future, but what a pain this time around.

Urgh.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

The author does not allow comments to this entry

Add Comment

E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Textile-formatting allowed