flutter - 在两个系统(Android 和 iOS)上再现视频时出现问题

标签 flutter android-video-player video-player

我正在 Flutter 应用中实现视频播放器功能,但我不明白哪种视频格式在两个系统(IOS 和 Android)上都适用。

我使用 video_player 0.10.0+2 和 chewie 0.9.6。

实际上,我们将 H264 与容器 MKV 一起使用,将 H265 与容器 MP4 (HEVC) 一起使用,但在 IOS(真实设备)上不起作用,在 Android 上也能正常工作,但有一些错误。

一些代码...

// 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;    
  }

在真实设备上的 IOS 中,视频无法在没有错误消息的情况下播放。

在 Android 中视频正在播放,但存在以下问题:

1) 日志错误:

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) 循环不工作

哪种格式最适合在两个系统上实现最大兼容性?

最佳答案

支持的视频格式实际上有很好的记录:

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.

我很幸运地得到了另一位 stackoverflow question 提供的建议并简单地使用以下 ffmpeg 格式进行转换:

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

这适用于 iOS(真实设备)和安卓设备。

FWIW:你显然也可以找到 the list of supported iOS formats in an SO answer如果您不想在您的设备上查询它们。

关于flutter - 在两个系统(Android 和 iOS)上再现视频时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55326957/

相关文章:

Flutter - 将来自不同文本字段的值相乘

android - 如何将 Flutter 应用锁定到 Kiosk 应用?

android - 如何将protobuf添加到flutter/kotlin android项目中

Android放弃音频焦点

mp4 - 无法从 SD 卡在 VideoView 中打开播放此视频

ajax - 初始化 youtube api 以定位 ajax 加载的 iframe

flutter - 将 cupertino 小部件与 Material 脚手架一起使用

android - Google TV 应用可显示来自 HDHomeRun Prime 的 MPEG2 流

audio - 音频 channel 布局

javascript - 奇怪的 Safari 视频 "Load"行为