Reputation: 3116
I'm implementing video player functionality in a Flutter app but I don't understand which is the best video format that work in both systems (IOS & Android).
I use video_player 0.10.0+2 and chewie 0.9.6.
Actually we're using H264 with container MKV and H265 with container MP4 (HEVC) but on IOS (real device) doesnt' work and in Android works but with some errors.
Some piece of code...
// Declaration
VideoPlayerController _playerController;
// Initialization
if (_playerController == null) {
_playerController = VideoPlayerController.network(_myVideoUrl)
..setVolume(0.0)
..setLooping(true)
..initialize();
}
//Play
_playerController.play();
//Stop
if (_playerController != null) {
_playerController.pause();
}
@override
void deactivate() {
super.deactivate();
if (_playerController != null) {
_playerController.pause();
}
}
@override
void dispose() {
super.dispose();
if (_playerController != null) {
_playerController.pause();
}
_playerController = null;
}
In IOS on real devices the video are not playing without error message.
In Android the video are playing but with these problems:
1) Log Error:
2019-03-24 15:30:49.468 1739-1817/? E/OMXNodeInstance: getExtensionIndex(0xf411c240:google.h264.decoder, OMX.google.android.index.enableAndroidNativeBuffers) ERROR: UnsupportedIndex(0x8000101a)
2019-03-24 15:30:49.468 16136-16335/it.itasoft.moc E/ACodec: [OMX.google.h264.decoder] setPortMode on output to DynamicANWBuffer failed w/ err -1010
2019-03-24 15:30:49.472 1739-1817/? E/OMXNodeInstance: setConfig(0xf411c240:google.h264.decoder, ConfigPriority(0x6f800002)) ERROR: UnsupportedIndex(0x8000101a)
2019-03-24 15:30:49.473 1739-1817/? E/OMXNodeInstance: getConfig(0xf411c240:google.h264.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: UnsupportedIndex(0x8000101a)
2019-03-24 15:30:49.475 1739-1817/? E/OMXNodeInstance: getConfig(0xf411c240:google.h264.decoder, ??(0x7f000003)) ERROR: UnsupportedSetting(0x80001019)
2019-03-24 15:30:49.554 1739-1817/? E/OMXNodeInstance: getConfig(0xf411c240:google.h264.decoder, ??(0x7f000003)) ERROR: UnsupportedSetting(0x80001019)
2019-03-24 15:30:49.558 1739-2059/? E/OMXNodeInstance: setConfig(0xf411c720:google.aac.decoder, ConfigPriority(0x6f800002)) ERROR: Undefined(0x80001001)
2019-03-24 15:30:49.559 1739-2059/? E/OMXNodeInstance: setConfig(0xf411c720:google.aac.decoder, ConfigOperatingRate(0x6f800003)) ERROR: Undefined(0x80001001)
2019-03-24 15:30:49.559 1739-2059/? E/OMXNodeInstance: getConfig(0xf411c720:google.aac.decoder, ConfigAndroidVendorExtension(0x6f100004)) ERROR: Undefined(0x80001001)
2) Loop doesn't work
Which formats are the best for maximize compatibility on both system?
Upvotes: 0
Views: 2869
Reputation: 4893
The supported video formats are actually quite good documented:
On iOS, the backing player is AVPlayer. The supported formats vary depending on the version of iOS, AVURLAsset class has audiovisualTypes that you can query for supported av formats. On Android, the backing player is ExoPlayer, please refer here for list of supported formats.
I had good luck with the the suggestions provided by another stackoverflow question and simply used the following ffmpeg format for conversion:
ffmpeg -i input.file.mp4 -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:360 -threads 0 -acodec libvo_aacenc -b:a 128k converted.mp4
this works on iOS (real device) and android devices just fine.
FWIW: You can obviously also find the list of supported iOS formats in an SO answer if you don't want to query them on your device.
Upvotes: 2