This uses the ffmpeg command line, which we use to transcode to MPEG-4 h.264 in our production environment. We tested the output on several Android devices, as well as on iOS. You can use this as a starting point by simply tweaking things like frame size / frame rate and qfactor.
ffmpeg -y -i
Some of the important parameters that affect Android compatibility are:
-coder 0 Uses CAVLAC rather than CABAC entropy encoding (CABAC not supported on Android) -trellis 0 Should be shut off, requires CABAC -bf 0 Turns off B-frames, not supported on Android or other h.264 Baseline Profile devices -subq 6 Determines what algorithms are used for subpixel motion searching. 7 applies to B-frames, not supported on Android. -refs 5 Determines how many frames are referenced prior to the current frame. Increasing this number could affect compatibility
After encoding our video using this ffmpeg recipe, we also transfer the video through qt-faststart . This step repeats the video for streaming. We send it via HTTP to the embedded VideoView in our Android application. No streaming issues on any Android device we know about.
Update 2013-06-17: I just wanted to add a note that it is best to use a “base” profile for H.264 encoding for maximum compatibility on all Android devices. The H.264 profile is not explicitly specified in the command line above, but ffmpeg has a -profile command line flag which is useful if you use its presets . You should probably not be confused with -profile . I encoded the video for my tablet ASUS Transformer 300 (Android 4.2) using the "main" and not the "basic" profile (via Handbrake). The "main" profile gave problems with the synchronization of sound with video during playback.
mportuesisf Jun 15 2018-11-11T00: 00Z
source share