flutter_packages
flutter_packages copied to clipboard
gstreamer_video_player - issue on looping
@ardera I'm facing this issue on looping the video.
plugins/gstreamer_video_player/player.c: last gstreamer state change failed. gst_element_get_state(element name: pipeline0): GST_STATE_CHANGE_FAILURE
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(nativeerror, Input/output error, 5, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:652:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:310:18)
<asynchronous suspension>
#2 FlutterpiVideoPlayer.getPosition (package:flutterpi_gstreamer_video_player/src/platform.dart:155:20)
<asynchronous suspension>
#3 VideoPlayerController._applyPlayPause.<anonymous closure> (package:video_player/video_player.dart:582:41)
<asynchronous suspension>
Any possible solution to loop the video, the code used is from the example of the package.
Fixed rebuilding the app, strange.
I've tested for looping 10 minutes and some times still happen, how can i manage this exception? The unwanted output is that the app stop the videi and the only way is to kill and relaunch the app.
Have you found any solution? I've got the same error.
Same problem here. I'm using a pi zero2, the video loops ok then stops.
Dec 05 08:20:52 fireplace flutter-pi[1278]: plugins/gstreamer_video_player/player.c: last gstreamer state change failed. gst_element_get_state(element name: pipeline0): GST_STATE_CHANGE_FAILURE Dec 05 08:20:52 fireplace flutter-pi[1278]: [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(nativeerror, Input/output error, 5, null) Dec 05 08:20:52 fireplace flutter-pi[1278]: #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651) Dec 05 08:20:52 fireplace flutter-pi[1278]: #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:322) Dec 05 08:20:52 fireplace flutter-pi[1278]: <asynchronous suspension> Dec 05 08:20:52 fireplace flutter-pi[1278]: #2 FlutterpiVideoPlayer.getPosition (package:flutterpi_gstreamer_video_player/src/platform.dart:155) Dec 05 08:20:52 fireplace flutter-pi[1278]: <asynchronous suspension> Dec 05 08:20:52 fireplace flutter-pi[1278]: #3 VideoPlayerController._applyPlayPause.<anonymous closure> (package:video_player/video_player.dart:582) Dec 05 08:20:52 fireplace flutter-pi[1278]: <asynchronous suspension>
Does the player allow an array of looping videos?
Okay, I've reproduced it, it seems to be either kernel or gstreamer related. Somehow, sometimes on end of stream, the buffer sharing between kernel and gstreamer gets confused - gstreamer thinks some buffer is currently not queued/used in kernel, but some time later it dequeues that exact buffer from the kernel and emits a stream error because that shouldn't have been possible. Though no idea what causes it.
As a super hacky workaround, one could create a new video player controller in flutter at every end of stream.
Do we already have a fix for this problem? Or is @ardera suggested workaround the best we have?
Facing the same problem here.
** (flutter-pi:850): WARNING **: 09:46:52.917: v4l2h264dec0: 1 frames 903-903 left undrained after CMD_STOP, eos sent too early: bug in decoder -- please file a bug
(flutter-pi:850): GStreamer-CRITICAL **: 09:46:52.967: gst_sample_set_caps: assertion 'gst_sample_is_writable (sample)' failed
** (flutter-pi:850): WARNING **: 09:47:01.927: v4l2h264dec0: 1 frames 1129-1129 left undrained after CMD_STOP, eos sent too early: bug in decoder -- please file a bug
plugins/gstreamer_video_player/player.c: gstreamer error: code: 1, domain: gst-stream-error-quark, msg: Internal data stream error. (debug info: ../gst/isomp4/qtdemux.c(6937): gst_qtdemux_loop (): /GstPipeline:pipeline0/GstURIDecodeBin:src/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason error (-5))
plugins/gstreamer_video_player/player.c: last gstreamer state change failed. gst_element_get_state(element name: pipeline0): GST_STATE_CHANGE_FAILURE
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(nativeerror, Input/output error, 5, null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
<asynchronous suspension>
#2 FlutterpiVideoPlayer.getPosition (package:flutterpi_gstreamer_video_player/src/platform.dart:155:20)
<asynchronous suspension>
#3 VideoPlayerController._applyPlayPause.<anonymous closure> (package:video_player/video_player.dart:586:41)
<asynchronous suspension>
Hi @Krakert I ended up buying a Pi5 and it now runs for months looping and i've not experienced any hanging. (Amazing job @ardera) I tried the replacing the player after each loop but it still stopped for me.
I'm not sure whether it was 32bit PiZero or it running out of ram or just some odd video driver issues.
@doug-ecofixa Hmm oke, strange.. I also tried replacing the controller after each video without any luck.
i build the assets with flutterpi_tool build --cpu=pi4
(when i define the --arch=arm64 it is unable to find the engine?)
class BannerPlayer extends StatefulWidget {
final String asset;
final bool setLooping;
final Duration restartDelay; // Duration for restart delay
const BannerPlayer(
{super.key,
required this.asset,
required this.setLooping,
required this.restartDelay});
@override
State<BannerPlayer> createState() => _BannerPlayerState();
}
class _BannerPlayerState extends State<BannerPlayer> {
late VideoPlayerController _controller;
@override
void initState() {
super.initState();
_initializeVideoPlayer();
}
void _initializeVideoPlayer() {
_controller = VideoPlayerController.asset(widget.asset)
..initialize().then((_) {
_controller.play();
setState(() {});
});
_controller.addListener(() {
if (_controller.value.position == _controller.value.duration) {
_restartVideoAfterDelay();
}
});
}
void _restartVideoAfterDelay() {
Timer(widget.restartDelay, () {
_initializeVideoPlayer();
});
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller));
}
}
After a undefined time it stops working.
That's interesting as i build it with this: flutterpi_tool build --release --cpu=pi4 --arch=arm64
- i'm on version 0.1.2 - It then runs on a pi5
This was before there was arm mac support (i think that exists now) so i ended up creating a docker container which runs as a gitlab pipeline to do the build and deploy.
@Krakert Do you really have a 64-bit OS installed on your Pi 5? If you're using 32-bit Raspberry Pi OS, you need to specify --arch=arm
(or leave it unspecified, because that's what it defaults to :) )
@ardera I have a Raspad 3 which is a Raspberry Pi 4 Model B Rev 1.4
$ neofetch
OS: Raspbian GNU/Linux 12 (bookworm) aarch64
Host: Raspberry Pi 4 Model B Rev 1.4
Kernel: 6.6.47+rpt-rpi-v8
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 12 (bookworm)"
NAME="Raspbian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
$ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm
$ uname -i
unknown
So im not sure on what version im on.