How to get your clips on the web
H264 has it all. Buy-in from the big content providers, compression ratio superiority, mobile device support, and support in all major video editing tools and operating systems. Many people seem to criticize Mozilla for being idealistic and not providing its users what “they want”.
Chris Blizzard wrote a great summary of why Mozilla isn’t endorsing h264 and herding its users into the patent holder’s stall with historic examples of GIF and mp3.
Big players might have their reasons to go with h264, but individual small publishers (aka blog posters, you & me) can already publish in this safer format (Currently both Firefox 3.5+ and Chrome 4 support Ogg Theora playback and Opera will). An observant reader might realize there’s quite a hole in this free argument as most of the content you’ll shoot, you’ll probably shoot on an AVCHD camera and thus will need an h264 decoder to eventually get to the free format. But who knows, maybe we’ll see some cheap Theora cams once the MPEG LA starts collecting form hardware vendors. Instead of drowning in this catch-22 I’ll give you a few practical tips on how to produce Ogg Theora video.
The multiplatform way to encode to ogg theora I found was vlc. Ironically most Linux distributions cannot legally distribute it as it contains all the other proprietary codecs to be useful. On openSUSE, you can grab it from the Packman repository. Another tool with similar limitations is ffmpeg2theora. VLC has the benefit of having a GUI for the conversion. But it does allow you to do this on the commandline:
vlc foo.avi --sout-theora-quality=5 --sout-vorbis-quality=1 \
--sout="#transcode{vcodec=theo,vb=800,scale=1,deinterlace=0,\
acodec=vorb,ab=128,channels=2,samplerate=44100}:standard{access=file,\
mux=ogg,dst='foo.ogv'}"
I would be thankful if a good soul would use the comment area here to provide a gstreamer pipeline to encode a file into ogg theora (extra hugs for a series of still images and audio muxing).
Update! Apart from getting that pipeline, I was pointed to what appears to be a nice no-nonsense OggTheora converter (does Schroedinger and vorbis as well) – OggConvert. Thanks!
On the Mac, I haven’t had much luck with the official Xiph quicktime components in the past. What worked for me was the Perian bundle. After installing the components to /Library/Quicktime/Components/ apps like iMovie are able to export to Ogg Theora.
How about MS Windows? Xiph provides direct show plugins for Theora. This should provide a system wide decoding and encoding. I can’t give any recommendations on converters, but I bet you can use Handbrake, which is also sweet on Linux & OS X.
HTML Embedding
So should you rip you DVD collection into Theora? Probably inefficient and impractical. Should you publish your videos in ogg theora as a primary format? Most definitely! So how to do that?
The primary way to embed a video stream is using HTML5’s video tag. This gives you a chance to control the video from javascript and provide means to fall back to other codecs. But let’s start with the basic markup:
<video width="640" height="480"> <source type="video/ogg" src="foo.ogg"> <!-- and a fallback for h264 --> <source type="video/mp4" src="foo.mp4"> </video>
Notice we already have the HTML5 supporting browsers covered. Now all the rest we cover with a Flash fallback. My suggestion is to use Flowplayer. I believe you can use the h264 mp4 stream directly with it, but if you want to support older flash plugins, you need to re-encode your clip to FLV (yay!). You can use ffmpeg and flvtool (to fix the metadata and index and allow flawless seeking).
Browsers unaware of the <video> tag will render the markup inside it (which is ignore by the HTML5 browsers). As this is a fallback, I went for a non-standard <embed> markup that is supported by more browsers, but you may stick with <object> to be more kosher. Additionally, IE6 does things its own way, so the markup ends up looking slightly ugly with the comment conditionals:
<video width="640" height="480">
<source type="video/ogg" src="foo.ogg">
<!-- and a fallback for h264 -->
<source type="video/mp4" src="foo.mp4">
<!-- and a fallback for flash9+ -->
<!--[if !IE]> <-->
<object type="application/x-shockwave-flash" data="flowplayer.swf" width="640" height="480">
<param name="movie" value="flowplayer.swf"></param>
<param name="wmode" value="transparent"></param>
<param name="allowfullscreen" value="true"></param>
<param name="flashvars" value='config={"clip":{"url":"http://yoursite/foo.flv"},"plugins":{"controls":{"time":false,"volume":false}}}'></param>
<!--> <![endif]-->
<embed width="640" height="480" type="application/x-shockwave-flash" src="/flowplayer.swf"
flashvars='config={"clip":{"url":"http://youriste/foo.flv"},"plugins":{"controls":{"time":false,"volume":false}}}'>
<!--[if !IE]> <-->
<!-- and a fallback for direct download -->
<h3>Oops!</h3>
<p>Sadly we weren't able to detect any plugins that would allow us to stream
the video to you. You can <a href="foo.mp4">download
the file</a< to watch it locally.</p>
<!--> <![endif]-->
</embed>
<!--[if !IE]> <-->
</object>
<!--> <![endif]-->
</video>
I hope this is a useful introduction on how to put your videos on the web. Feel free to correct me in the comments or give some more tips for everyone!
Update – Added OggConvert to the encoding section.
January 25th, 2010 at 3:39 pm
For encoding there is also http://firefogg.org/ which is build upon ffmpeg2theora and allows people having the firefogg addon installed to upload/transcode video through a site.
January 25th, 2010 at 3:55 pm
And what about cortado java applet from fluendo?
http://www.flumotion.net/cortado/
It needs java, but a quick, unscientific test shows cortado applet playing ogg/theora video need less cpu than flash playing same video in mp4
January 25th, 2010 at 4:33 pm
A suitable GStreamer pipeline would be
gst-launch-0.10 filesrc location=/path/to/video/file.ext ! decodebin name=dbin dbin. ! queue ! ffmpegcolorspace ! theoraenc quality=32 ! queue ! mux. dbin. ! queue ! audioconvert ! vorbisenc quality=0.2 ! queue ! mux. oggmux name=mux ! progressreport ! filesink location=/output/path.ogv
This is more-or-less the pipeline I use in OggConvert
January 25th, 2010 at 4:36 pm
@fabrixxm: Indeed the Cortado applet seems like a decent fallback for people not wanting to deal with transcoding and only provide Theora. In theory at least.
Sadly my experience with Java is that it’s extremely fragile and will get a very high number of complains/bugreports if you use applets. But as a fallback only it might work for the lazy blogger.
@Tristan: Big hug! Works great!
January 25th, 2010 at 5:13 pm
I don’t criticize Mozilla/Firefox for promoting a free standard. What I criticize them for is for doing a/v support directly, rather than just relying on the system codecs. On Linux, this means that if I do go buy a licensed codec from Fluendo, that I *still* can’t view video on the sites that stream their content in that format. *This* is a bad thing. It’s also bad, because there are other *free* formats that Mozilla/Firefox probably don’t support, but GStreamer will.
System integration fail.
January 25th, 2010 at 5:18 pm
Well system codecs isn’t a solution in my opinion, but the initial problem. It’s actually what Flash was a solution for.
January 25th, 2010 at 6:20 pm
Flash isn’t a solution for the system codecs problem. Flash was a solution for the lack of , and not wanting to develop yet another crappy plug-in. There used to be lots of video player plug-ins, before everyone just switched to using Flash.
There is no easy way to guarantee everyone is going to have the ability to play back a certain audio or video codec, regardless of whether it is handled by the system’s media framework, the web vm, or a plug-in like Flash. Flash doesn’t work on every system, or in every web vm, either. There is no Total Solution. There is no trying. There’s doing it right, and fucking it up royally. And right now, everyone is fucking it up royally.
January 25th, 2010 at 6:31 pm
The real usefulness of Flash was precisely this — large scale deployment and availability of a common codec.
January 25th, 2010 at 6:49 pm
Care to put some demo online?
Would be nice to have some in this article.
January 25th, 2010 at 7:12 pm
khiraly: check out http://susestudio.com/#screencast
January 25th, 2010 at 10:24 pm
If that was the real usefulness of Flash, then there wouldn’t be a million different video player UIs for it. There would be one, and it would play all video on the web. But there isn’t and it doesn’t.
Flash only became a real opportunity for playing video after YouTube became popular. Before that, very few people used Flash to play videos on their sites, and if they did, it was just an MPEG video embedded in the Flash object directly. The ones that didn’t just embedded wmv videos, which required a plug-in to view. Only supporting Theora in Moz/Firefox isn’t going to get people to release their content in Theora. It’s going to get more people to use Chrome. But if that’s what Mozilla wants, then I guess they’ll succeed.
January 26th, 2010 at 10:03 am
From the tools described above, my favorite transcoder is ffmpeg2theora, easy to remember, easy to use, can be scripted.
However, I feel your extensive guide could use a section about hosting, unlike photos, videos tend to have large file size and self-hosting them may not be always a solution. Currently I use blip.tv, which accept .OGV but has his share of problems with the format.
January 26th, 2010 at 3:27 pm
Nice writeup; this might be useful content for the Theora wiki (or wherever people would likely look for this).
What I’m not yet clear on is how to display Theora to Internet Explorer users. Does the Cortado applet work fine for that? And does IE make it easy for users to download and install the applet (ie. how many clicks does it take novice users to view my embedded Theora video in IE)?
January 27th, 2010 at 12:58 am
Don’t forget Arista and Transmageddon in the transcoders list…
http://programmer-art.org/projects/arista-transcoder
http://www.linuxrising.org/transmageddon/
January 28th, 2010 at 12:03 am
Great article! I’ve been collecting some ways to encode to Ogg Theora on my wiki for a while, but it doesn’t have “modern” ways to do it, like using GStreamer.
For those who want to use ffmpeg, I should Bernhard Rosenkraenzer wrote a script that uses mencoder and the reference Theora encoder together. AFAIK mencoder’s output quality tends to be better than ffmpeg.
January 28th, 2010 at 5:52 pm
Your solution looks very similar to the Video for Everybody solution that I saw a while back; it seems to have almost all the corner cases covered, and all without Javascript.
January 31st, 2010 at 3:01 am
[...] � How to get your clips on the web [...]