Theoretically both IOS and ANDROID will play h.264 files, but I can't figure out a setting to encode them so they actually work cross platform. Does anybody know how to encode for both Android and IOS using one file?
p.s. I know all about html5 video and the fallback sources, I just don't want to encode and host a new video for every device that comes down the pike.
See Android Supported Media Formats,
which states that h.264 is only supported in Android 3.0+. Earlier versions of Android support h.263.EDIT: As mportuesisf mentions below, I misinterpreted the linked table. Ignore this answer.Here's the ffmpeg command line we use to transcode to MPEG-4 h.264 in our production environment. We've tested the output on several Android devices, as well as iOS. You can use this as a starting point, just tweaking things like frame size/frame rate and qfactor.
Some of the important options affecting Android compatibility are:
After we encode our video with this ffmpeg recipe, we also pass the video through qt-faststart. This step rechunks the video for streaming. We stream it over HTTP to an embedded VideoView within our Android app. No problems streaming to any Android device we're aware of.
Update 2013-06-17: I just wanted to add a note that it's best to stick with "baseline" profile for H.264 encoding for maximum compatibility across all Android devices. The above command line doesn't explicitly specify an H.264 profile, but ffmpeg does have a
-profile
command line flag that is useful if you are using its presets. You probably shouldn't mess with-profile
. I have encoded videos for my ASUS Transformer 300 tablet (Android 4.2) using "main" rather than "baseline" profile (via Handbrake). The "main" profile gave problems with audio getting out of sync with video on playback.I used this to make an Android and iOS app with embedded videos. The videos played in both versions. (Android example) (iOS example)
Supplemental answer
This answer is a supplement to the accepted answer explaining some of the parameters.
Feel free to edit this if you can fill in some of the details I wasn't sure about.
Here it is again in a cut-and-paste format. (I also had to add the
-strict -2
parameter to getaac
to work on my computer.)Further Study
Most of this information I found at the following links:
See also