-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Closed as not planned
Labels
r: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issue
Description
Hello, support team!
Hope you are doing well.
I am using video_player package for my video sharing app (like tiktok). To play the video without delay time, I've converted mp4 to HLS(m3u8) and my app plays the HLS videos to users. But still have some delay time on playing each videos.
So I tried to load the next/prev videos when play current video. It looks like working fine for a moment. But the problem is that if I load more than 10 or more videos, videoPlayerController is not able to initialize the video anymore.
Expected results: can load multiple videos at the same time
Actual results: not able to keep 2 or more controllers at the same time
Code sample
==================== Initialize the videoPlayerController =================
class VideoService {
static final Map<String, VideoPlayerController> _controllers = {};
static Future<VideoPlayerController> initializeOnlineVideoPlayer(
String url,
) async {
if (_controllers.containsKey(url)) return _controllers[url]!;
var a = Uri.parse(url);
VideoFormat? videoFormat;
if (a.pathSegments.last.endsWith('m3u8')) {
videoFormat = VideoFormat.hls;
} else if (a.pathSegments.last.endsWith('mp4')) {
videoFormat = VideoFormat.other;
} else if (a.pathSegments.last.endsWith('mkv')) {
videoFormat = VideoFormat.dash;
}
VideoPlayerOptions options = VideoPlayerOptions(mixWithOthers: true);
VideoPlayerController _controller;
_controller = VideoPlayerController.network(
url,
formatHint: videoFormat,
videoPlayerOptions: options,
);
_controller.setLooping(true);
if (AppConfig.getMute) {
_controller.setVolume(0);
} else {
_controller.setVolume(100);
}
try {
await _controller.initialize();
_controllers[url] = _controller;
} catch (e) {
debugPrint('Initialize online video player error: $e');
}
return _controller;
}
}
====================== Request to load video ===========================
PageView.builder(
key: const Key('timeline'),
controller: _controller,
scrollDirection: Axis.vertical,
itemCount: provider.timelinePosts?.length,
itemBuilder: (context, index) => VideoWidget(),
onPageChanged: (index) {
var isPostInitialized = VideoService.isPostInitialized(
provider.timelinePosts![index],
);
if (!isPostInitialized) {
_controller.jumpToPage(index - 1);
return;
}
List<Future> futures = [];
for (var i = 1; i <= 1; i++) {
var prevIndex = index - i;
var nextIndex = index + i;
if (prevIndex > 0) {
futures.add(VideoService.initializePostVideos(
provider.timelinePosts![prevIndex],
));
}
if (nextIndex < provider.timelinePosts!.length - 1) {
futures.add(VideoService.initializePostVideos(
provider.timelinePosts![nextIndex],
));
}
}
Future.wait(futures);
},
)Logs
PlatformException(VideoError, Video player had error com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(0, null, null, video/avc, avc1.64001F, -1, null, [720, 1280, -1.0], [-1, -1]), format_supported=YES, null, null)
D/MediaCodecInfo(14957): AssumedSupport [sizeAndRate.rotated, 720x1280x-1.0] [OMX.google.h264.decoder, video/avc] [HWDUB-Q, DUB-AL00, HUAWEI, 27]
I/OMXClient(14957): Treble IOmx obtained
W/ACodec (14957): Allocating component 'OMX.qcom.video.decoder.avc' failed, try next one.
E/ACodec (14957): Unable to instantiate codec 'OMX.qcom.video.decoder.avc' with err 0xfffffff4.
E/ACodec (14957): signalError(omxError 0xfffffff4, internalError -12)
E/MediaCodec(14957): Codec reported err 0xfffffff4, actionCode 0, while in state 1
W/MediaCodec-JNI(14957): try to release MediaCodec from JMediaCodec::~JMediaCodec()...
W/MediaCodec-JNI(14957): done releasing MediaCodec from JMediaCodec::~JMediaCodec().
W/MediaCodecRenderer(14957): Preferred decoder instantiation failed. Sleeping for 50ms then retrying.
I/OMXClient(14957): Treble IOmx obtained
W/ACodec (14957): Allocating component 'OMX.qcom.video.decoder.avc' failed, try next one.
E/ACodec (14957): Unable to instantiate codec 'OMX.qcom.video.decoder.avc' with err 0xfffffff4.
E/ACodec (14957): signalError(omxError 0xfffffff4, internalError -12)
E/MediaCodec(14957): Codec reported err 0xfffffff4, actionCode 0, while in state 1
W/MediaCodec-JNI(14957): try to release MediaCodec from JMediaCodec::~JMediaCodec()...
W/MediaCodec-JNI(14957): done releasing MediaCodec from JMediaCodec::~JMediaCodec().
W/MediaCodecRenderer(14957): Failed to initialize decoder: OMX.qcom.video.decoder.avc
W/MediaCodecRenderer(14957): android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.avc, error 0xfffffff4
W/MediaCodecRenderer(14957): at android.media.MediaCodec.native_setup(Native Method)
W/MediaCodecRenderer(14957): at android.media.MediaCodec.<init>(MediaCodec.java:1801)
W/MediaCodecRenderer(14957): at android.media.MediaCodec.createByCodecName(MediaCodec.java:1782)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createCodec(SynchronousMediaCodecAdapter.java:74)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createAdapter(SynchronousMediaCodecAdapter.java:49)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(DefaultMediaCodecAdapterFactory.java:130)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1095)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1006)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:546)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1437)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:799)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:950)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:779)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:998)
W/MediaCodecRenderer(14957): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499)
W/MediaCodecRenderer(14957): at android.os.Handler.dispatchMessage(Handler.java:105)
W/MediaCodecRenderer(14957): at android.os.Looper.loop(Looper.java:166)
W/MediaCodecRenderer(14957): at android.os.HandlerThread.run(HandlerThread.java:65)
E/MediaCodecVideoRenderer(14957): Video codec error
E/MediaCodecVideoRenderer(14957): com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(0, null, null, video/avc, avc1.64001F, -1, null, [720, 1280, -1.0], [-1, -1])
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1017)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecOrBypass(MediaCodecRenderer.java:546)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1437)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:799)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.readSourceOmittingSampleData(MediaCodecRenderer.java:950)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:779)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:998)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:499)
E/MediaCodecVideoRenderer(14957): at android.os.Handler.dispatchMessage(Handler.java:105)
E/MediaCodecVideoRenderer(14957): at android.os.Looper.loop(Looper.java:166)
E/MediaCodecVideoRenderer(14957): at android.os.HandlerThread.run(HandlerThread.java:65)
E/MediaCodecVideoRenderer(14957): Caused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.avc, error 0xfffffff4
E/MediaCodecVideoRenderer(14957): at android.media.MediaCodec.native_setup(Native Method)
E/MediaCodecVideoRenderer(14957): at android.media.MediaCodec.<init>(MediaCodec.java:1801)
E/MediaCodecVideoRenderer(14957): at android.media.MediaCodec.createByCodecName(MediaCodec.java:1782)
at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createCodec(SynchronousMediaCodecAdapter.java:74)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.SynchronousMediaCodecAdapter$Factory.createAdapter(SynchronousMediaCodecAdapter.java:49)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.DefaultMediaCodecAdapterFactory.createAdapter(DefaultMediaCodecAdapterFactory.java:130)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:1095)
E/MediaCodecVideoRenderer(14957): at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodecWithFallback(MediaCodecRenderer.java:1006)
E/MediaCodecVideoRenderer(14957): ... 10 more
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.2.1 21D62 darwin-x64, locale en-GB)
• Flutter version 3.0.5 at /Users/macbookair/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (4 weeks ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at /Users/macbookair/Library/Android/sdk
• Platform android-33, build-tools 33.0.0
• ANDROID_HOME = /Users/macbookair/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] VS Code (version 1.70.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.46.0
[✓] Connected device (3 available)
• DUB AL00 (mobile) • 192.168.1.101:5555 • android-arm64 • Android 8.1.0 (API 27)
• macOS (desktop) • macos • darwin-x64 • macOS 12.2.1 21D62 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 104.0.5112.79
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Metadata
Metadata
Assignees
Labels
r: duplicateIssue is closed as a duplicate of an existing issueIssue is closed as a duplicate of an existing issue