Wednesday, 7 August 2013

MediaPlayer fails to prepare one stream with identical encoding to another

MediaPlayer fails to prepare one stream with identical encoding to another

Interesting situation for you, I have two near identical video files to
play, they both work on most devices but on a handful of devices, one of
them fails with the (1,-2147483648) MediaPlayer Generic/Unknown error,
displaying the "Can't play this video" pop-up. The devices include an LG
Nexus 4 running 4.3, devices running 4.1.2 and a Samsung galaxy S3. To
complicate things further the Galaxy S3 successfully plays the audio, but
not the picture.
Here is the ffmpeg metadata output for both files:
Successful file:
Metadata: major_brand : 3gr6 minor_version : 0 compatible_brands:
3gr63gp63gg63gp43gp5isom creation_time : 2013-06-17 09:51:10 Duration:
00:01:40.64, start: 0.000000, bitrate: 330 Stream #0:0(eng): Video: h264
(Baseline) (avc1 / 0 70 [SAR 1:1 DAR 16:9], 248 kb/s, 25 fps, 25 tbr, 2500
Metadata: creation_time : 2013-06-17 09:51:10 handler_name : Popwire Video
Media Handler Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), kb/s
Metadata: creation_time : 2013-06-17 09:51:10 handler_name : Popwire Sound
Media Handler
Broken File;
Metadata: major_brand : 3gr6 minor_version : 0 compatible_brands:
3gr63gp63gg63gp43gp5isom creation_time : 2012-02-24 12:16:20 Duration:
00:01:00.56, start: 0.000000, bitrate: 331 Stream #0:0(eng): Video: h264
(Baseline) (avc1 / 0 70 [SAR 1:1 DAR 16:9], 248 kb/s, 25 fps, 25 tbr, 2500
Metadata: creation_time : 2012-02-24 12:16:20 handler_name : Popwire Video
Media Handler Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), kb/s
Metadata: creation_time : 2012-02-24 12:16:20 handler_name : Popwire Sound
Media Handler
Some may have been cut-off so I can redo that in an edit if necessary but
basically the only difference between the two files is the working file is
4 megabytes in size and the broken file is 2 megabytes and a year older.
They are both in h264 baseline profile as you can see so should not be
having problems encoding wise.
The activity uses a custom video view with MediaPlayer and MediaController
set, i'm catching the error in the onErrorListener to look for the
-2147483648 code and report it as an unsupported video format on the
particular device but I'd obviously rather find the issues that's causing
this issue only on some devices. The onPrepareListener is never called for
the second file. I could download the files and try playing them
locally/making modifications but I'd rather stream them to avoid such a
delay for the user.
The files are both streamed from the same remote hosting site so can't
really be modified and have the .3gp file extension, no visible difference
in their location or filetype as mentioned above and the same code is used
for these and all other successful videos on instances of the activity.

No comments:

Post a Comment