2

I found MediaPlayer cannot play videos which are encoded by H.264 Main Profile and I tried ExoPlayer and Vitamio but none of them solved my problem. finally I found the best solution is converting videos to H.264 Baseline Profile. FFmpeg is almost 9MB and it's so heavy for my project, so I don't like to use it for converting videos to that profile by commands. My friend suggested converting videos on the server-side but we both know it has bad performance. What should I do? What is the best solution to this problem?

Alex
  • 1,623
  • 1
  • 24
  • 48

1 Answers1

6

Android technically only supports H.264 Baseline, but many of the newer (usually high end devices) will play H.264 Main Profile, too. The Nexus 4,5,6,7 and 10 all do, for example. So, you have a few options... You either just use H.264 Main and don't care about older devices that don't support it, or you convert on the server side. Doing the conversion on the device is a bad idea. If it doesn't support H.264 Baseline, it was probably done for performance reasons and doing the conversion on the device and then decoding is going to crush the CPU.

Worth noting, ExoPlayer will use the same device codecs as MediaPlayer because it is just a wrapper around MediaCodec. Vitamio is a wrapper around ffmpeg and it might be possible to provide a H.264 Main codec with a custom ffmpeg build, but again, if it isn't there in the first place, performance was probably an issue.

Kaleb
  • 1,855
  • 1
  • 18
  • 24
  • We're already converting videos on the server-side but we doubt in its performance. We think apps such as Instagram handles this issue in another way. We're struggling the issue for almost two months! If you know more about the issue and its solutions or you personally experienced it, share them with community including me please. – Alex Feb 19 '16 at 19:01
  • Supporting the most Android devices requires serving H.264 Baseline. Converting from Main or High requires a decode and an encode to remove B-frames to get to Baseline. Doing that on the device is not practical because the decode may not be supported in the first place. For companies that have the resources, I suspect they cache multiple formats and bitrates server side and then serve them up dynamically via fragmented MP4 (or something similar) based on what the device supports and the quality of the network. – Kaleb Feb 23 '16 at 15:09