Encode and deliver MP4 Video for Flash, iPhone, iPad, Android, Quicktime with timeshift possibility
A big challenge was to find a solution to encode and deliver videos for as much platforms as possible. The only thing that was clear I had to use mpeg4 for max. compatibility.
Initial Position: We have many PAL videos with up to 20 different languages. All are around an hour. They are organized in chapters.
Client needs:
- Multilanguage
- Timeshift / Pseudo-streaming / Random access to jump directly to a chapter
- Two different bandwidths
- Maximum quality
- Download security
- Platforms: Desktop (Flash), iPhone, iPad, Android and maybe more in the future
My main thought was, ok, many of the features needed will work with Adobes Flash Media Server. But how can I deliver skippable video to iDevices with the same comfort. And another challenge was the client’s network. It’s a big company so they have a firewall and a proxy with a strong content filter.
Server possibilities:
- Flash Media Server (rtmp and rtmpt via http tunneling, easy install, works out of the box)
- red5 (rtmp, not so easy to configure, java knowledge needed)
- Webserver only (http progressive download no skipping)
- xmoovstream (http, php script, random access for iDevices but not for mp4 in combination with flash)
- H264 streaming extension by trac for a variety of webservers (http, pseudo-streaming mp4 video for Flash and iDevices)
After some tests I made my decision to use Flash Media Server with the bundled Apache webserver extended by the h264 streaming extension. This works fine for all purposes and is in my opinion the best and easiest combination of rtmp and http with skipping directly into the video without loading it completely, I think it’s also called random access. And the best, you only need to store your files once on the server.
And now to the encoding part. It must be a fast encoding because we have many different audio languages, the video track is almost the same. The only way to do this, is the possibility to encode the video separately from the audio and muxing it together.
Encoding possibilities:
- Adobe Media Encoder (Good encoding quality, No muxing (maybe it can be done with external tools), sometimes the videos will not play on iDevices, Flash needs to be installed on the encoding computer)
- Sorenson Squeeze (No muxing(maybe it can be done with external tools), didn’t find any good quality encoding settings)
- ffmpeg in combination with mp4box (Good encoding quality, muxing possible, nothing needs to be installed on the encoding computer, just put the binaries, a batch file and the source files on the network or a external hard-drive and go)
It’s clear, that I used the last one. If you want to use it too, just google for some binaries for your operating system. Important is that you find a ffmpeg version with libx264 included.
Encoding settings:
Both are two pass encoding settings for best quality
High Quality (Video & Audio) – Flash, iPad, Quicktime (not on iPhone because this uses a better h264 profile the iPhone can’t play) maybe iPhone 4:
Pass 1;
Pass 2:
Low Quality (Video & Audio) (works on all platforms):
Pass 1:
Pass 2:
Adding the needed hinting stream and interleaving the stream in chunks (same for both):
mp4box -inter 500 -hint out-low.mp4
Audio only encoding
ffmpeg -y -i "audio-lc.wav" -acodec libfaac -ab 32k -ac 1 audio-lc-32.m4a
Muxing Audio and Video together
mp4box -add out-low.mp4#video out-low-lc.mp4
mp4box -inter 500 -hint out-low-lc.mp4<br/>
mp4box -add audio-lc-64.m4a#audio out-high-lc.mp4
mp4box -add out-high.mp4#video out-high-lc.mp4
mp4box -inter 500 -hint out-high-lc.mp4
A good player to test all this is the jw player. It is also available as html5 beta version so you can also try it on an iPad.
We are developing our own player because we need some special features like chaptermenus and subtitles.
Hope this can help someone. If you have some questions just ask in comments.
can you suggest what protocol should be used for delivering Mp4 VOD on Andriod and blackberry devices using the App’s
[…] mit FFmpeg wmv in mp4/h264 umwandlen – Kommandozeilenbeispiele: 19-ffmpeg-commands-for-all-needs how-to-convert-wmv-to-mp4 http://www.ketzler.de/: encode-and-deliver-mp4… […]
Here for compiled version for Mac/Windows/Linux : http://www.tkn.tu-berlin.de/research/evalvid/
Good question. I didn’t know it anymore. I googled mp4box and found some Windows Binaries.
Hello Christoph,
i just saw that fms4 came out and that the price now is much lower than it was for version 2.0
it seems like adobe realized that they where with their pricephil a way off..
marco
Hello Christoph,
ok, so if i add the stream with mp4box, then it is good.
can you tell me from where did you get it?
thank you
marco
Hello Marco
You are right. mp4box can write some data into the file for jumping directly into the file. But I’m not sure if wowza really needs it. I tried wowza just a little bit and, if I remember it right, it works without the hinting stream. But I can’t say it 100%.
I use mp4box most of the time to mux different audio and video streams to one file.
Hope this helps
Christoph
Hi
i am using the wowza server and i am trying if your parameters are working togehter with it.
i hope that i dont have to do all the conversion so deep in detail because the wowza should handle it with the build in features. i will keep you updated on that.
like is said i try to use the wms to do that, my server ist a debian lenny with selfcompiled ffmpeg to support mp3 for the flash part (normal pcs) but i dont have mp4box installed.
can you tell me how you have mp4box set up and for what im detail you need it?
i know that for ffmpeg you need flvtools2 to rewrite some hints into the flv that you can jump to any position in the movie. is mp4box used for that?
take care
marco
Hi
Yes, you are right. I tried it after I wrote this article and after we bought a FMS license. But for our next projects we have it in mind. Especially the live to iPhone streaming is a big feature.
Christoph
hi
give wowza media server a try, it can handle more things that flash media
tell me what you think
marco