Open MarcusWichelmann opened 3 years ago
I've now hooked a debugger into VLC for Android and checked which options it passes to libvlc to pass the same from my app. But had no luck, the playback is still laggy.
Parameters:
"--audio-time-stretch",
"--avcodec-skiploopfilter",
"1",
"--avcodec-skip-frame",
"0",
"--avcodec-skip-idct",
"0",
"--subsdec-encoding",
"",
"--stats",
"--android-display-chroma",
"RV16",
"--audio-resampler",
"soxr",
"--audiotrack-session-id=1985",
"--freetype-rel-fontsize=16",
"--freetype-color=16777215",
"--freetype-background-opacity=0",
"-vv",
"--no-sout-chromecast-audio-passthrough",
"--sout-chromecast-conversion-quality=2",
"--sout-keep",
"--preferred-resolution=-1",
"--aout=opensles",
The extended logging now shows some additional hints what might be the issue:
D/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture might be displayed late (missing 9 ms)
W/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture is too late to be displayed (missing 33 ms)
I/MediaCodecLogger( 2954): com.android.mediaplayer.HW.video.hevc Dropping frame
W/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture is too late to be displayed (missing 13 ms)
I/MediaCodecLogger( 2954): com.android.mediaplayer.HW.video.hevc Dropping frame
D/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture might be displayed late (missing 0 ms)
W/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture is too late to be displayed (missing 28 ms)
I/MediaCodecLogger( 2954): com.android.mediaplayer.HW.video.hevc Dropping frame
W/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture is too late to be displayed (missing 10 ms)
I/MediaCodecLogger( 2954): com.android.mediaplayer.HW.video.hevc Dropping frame
D/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture might be displayed late (missing 1 ms)
W/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture is too late to be displayed (missing 23 ms)
I/MediaCodecLogger( 2954): com.android.mediaplayer.HW.video.hevc Dropping frame
D/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture might be displayed late (missing 4 ms)
W/VLC ( 2954): [84dfb930/d0e] libvlc video output: picture is too late to be displayed (missing 10 ms)
...
But I still don't know how to fix this. :/
Did you test with HwAcc.Disabled? Also i googled about your problem, it seems that this issue is related to Fire TV device not the plugin.
Check this link https://emby.media/community/index.php?/topic/27322-stutteringchoppy-playback-lately-on-firetv-stick/ -->
"The Stick has very limited processing power so anything that requires processing power to decode could be an issue. For this reason, we don't allow the use of direct stream with VLC on the stick for any HD content."
Thanks for your fast response.
When disabling HwAcc, the stream still stutters the same (looks like ~15 FPS) but the HW decoder errors in logcat disappeared (of course).
Thanks for your link. But I'm not sure if this statement from 2015 is still relevant for the current generations of Fire TVs. Also, the stream runs absolutely fine in the official VLC for Android app, just not when embedding libvlc into flutter using this library. So maybe the embedding into Flutter introduces too much overhead?
Maybe it's worth to mention, that logcat is spammed with Invalid display
messages as long as the app is run in release-mode on the FireTV. These messages aren't there when running in debug-mode. But I'm not sure, if this is any related.
04-01 17:29:16.902 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:16.917 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:16.935 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:16.954 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:16.967 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:16.984 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.000 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.019 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.036 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.053 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.069 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.094 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.119 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.137 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.186 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.202 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.222 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.234 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.253 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.267 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.289 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.304 241 241 E HWComposer: getLayerReleaseFence: Invalid display
04-01 17:29:17.324 241 241 E HWComposer: getLayerReleaseFence: Invalid display
...
You said "This issue is also only present on the Fire TV and the stream runs fine on e.g. an Android Smartphone.". Did you test your app on an android smartphone too?
"So maybe the embedding into Flutter introduces too much overhead?" No, in flutter we only pass the parameters to the android platform.
Yeah, I ran the app on two Android Smartphones (bq Aquaris X, Pixel 4a 5G, smooth playback), on an Android TV emulator (smooth, too) and on the Fire TV 4K (stuttering). A friend also tried it on a Sony TV with Android TV (KD55XG8505) where he saw stuttering too, but less extreme. And I've just received a Chromecast with Google TV which I can test the app on on tuesday.
If you don't think that this issue could be caused by rendering overhead, then I'm really out of ideas now regarding what could be the difference between the Flutter VLC Player and VLC for Android.
please share the streaming url so we can test that.
We have same problem on MiBox4 issue 209
@MarcusWichelmann i had the same issue https://github.com/solid-software/flutter_vlc_player/issues/32, spent countless hours fiddling with vlc params but nothing worked. Finally i gave up on this plugin and used the amazon's exoplayer port which is well optimised to work with fire devices.
@alr2413 Unfortunately, I cannot share the streams I used for testing, but this should be reproducable with any HD/4K H.265 Stream.
@pharshdev Do you use ExoPlayer with Flutter or directly in Kotlin/Java? I noticed that, on some Android TVs, ExoPlayer in Flutter (video_player
) has similar laggs/low framerate like described above. But when using ExoPlayer without Flutter, the same devices were well able to play even 4K 60 FPS HDR streams smoothly without issues. It looks like that there is some optimization missing on the Flutter side because the issue seems to be not limited to only flutter_vlc_player
.
I decided to skip Flutter for now and write the app with native Android and the Java ExoPlayer APIs instead, because that way the videos will even play smoothly on low-end devices.
@MarcusWichelmann yes i used the exoplayer natively. For me flutter + native exoplayer works for now and i dont have to maintain separate code for mobile and tv devices.
@pharshdev So you embedded the ExoPlayer into a Flutter AndroidView? That's the same that video_player
does afaik and that didn't perform very well on some devices I tested it on.
@MarcusWichelmann nope, no embedding. I simply launch the PlayerActivity from the FlutterActivity with all the params necessary to play the video from the flutter side. Once the playback is done, I'm back to Flutter goodness.
@pharshdev Aah good idea, thank you. I'll see if that works for me.
@MarcusWichelmann @pharshdev, if you don't need to access any player parameters on flutter side that solution might work well.
@MarcusWichelmann nope, no embedding. I simply launch the PlayerActivity from the FlutterActivity with all the params necessary to play the video from the flutter side. Once the playback is done, I'm back to Flutter goodness.
Can you show a code example?
@jeffmikels I resolved this by showing a transparent Flutter app using a FlutterFragment as an overlay for the ExoPlayer view. See: https://flutter.dev/docs/development/add-to-app/android/add-flutter-fragment Communication with the player instance happens through method channels.
This strategy also works on iOS, even thought it's way less documented.
Unfortunately, I cannot share any code right now, but it should be fairly straight forwarded to implement with above documentation.
@pharshdev Do you happen to have an example of this? I've been hitting my head against a wall to get 4k60fps video working in Flutter (StackOverflow issue)
This might be the final breakthrough I need to getting this working for my scenario.
Hello, I'm working with the tv and ExoPlayer with native Kotlin and I'm not streaming media just playing from local I'm facing the same issue with FireStick 4K it crashes within 3 to 4 minutes and in FireStick Lite it's working up to 15 to 30 munites.
Hi,
when playing a HLS H.265/HEVC stream on a Fire TV 4K, the playback is very stuttering and the decoder seems to be dropping a lot of frames. This can also be seen in logcat where a lot of
com.android.mediaplayer.HW.video.hevc Dropping frame
messages appear just a few seconds after the stream has started playing.But when playing the same stream using the VLC app for Fire TV, the playback is smooth and the log output clean, so I suppose that VLC for Android passes some parameters to libvlc that I don't. But I have not yet discovered which these are.
Maybe you have an idea what options I'm missing?
My simple test code (the commented out options were some unsuccessful tests from me):
The stuttering is reproducable with above code as well as with the sample application from this repository (when changing the code to use my stream). Interestingly, this is not reproducable with this stream: http://demo.unified-streaming.com/video/tears-of-steel/tears-of-steel.ism/.m3u8.
This issue is also only present on the Fire TV and the stream runs fine on e.g. an Android Smartphone.
Information about my stream:
Log output: