Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin for flutter.io/videoPlayer #134

Open
chunhunghan opened this issue May 14, 2019 · 28 comments
Open

Plugin for flutter.io/videoPlayer #134

chunhunghan opened this issue May 14, 2019 · 28 comments
Labels
plugin Issue about an existing or possible plugin wontfix This will not be worked on

Comments

@chunhunghan
Copy link

Can we have video player plug-in for Windows?

Thank you for your amazing work.

Flutter version

Flutter 1.5.4-hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7a4c33425d (2 weeks ago) • 2019-04-29 11:05:24 -0700
Engine • revision 52c7a1e849
Tools • Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)

Go.mod file

module C:\go-flutter-master\example\test_template/desktop

go 1.12

require (
github.com/go-flutter-desktop/go-flutter v0.16.0
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 // indirect
github.com/pkg/errors v0.8.1
github.com/stretchr/objx v0.2.0 // indirect
)

@pchampio
Copy link
Member

Yes WE can, but work needs to be made on: #102 #103.
Once those issues are resolved we could implement the plugin

@GeertJohan GeertJohan added the plugin Issue about an existing or possible plugin label May 14, 2019
@GeertJohan GeertJohan changed the title windows : no handler found for channel flutter.io/videoPlayer Plugin for flutter.io/videoPlayer May 14, 2019
@pchampio
Copy link
Member

pchampio commented Jul 25, 2019

Progress on #102 has been made.
The Texture api is in beta release (use hover run -b '@beta' to test it)

The texture_tutorial has been updated with a video example.

What is left to do is to align ourself with the way the flutter.io/videoPlayer do things

@pchampio
Copy link
Member

pchampio commented Sep 3, 2019

Looking for maintainer: A first implementation is available at: https://github.com/go-flutter-desktop/plugins/tree/master/video_player
A partial rewrite needs to be done, more info in the video_player's readme.

@pchampio pchampio added wontfix This will not be worked on and removed wontfix This will not be worked on labels Nov 5, 2019
@j4qfrost
Copy link

j4qfrost commented Mar 5, 2020

I've reimplemented the backend logic using gocv here https://github.com/Knights-of-the-Functional-Calculus/gfd-plugins/blob/master/video_player/cv.go

It's still showing memory leaks. I can't find any place where it might be leaking in my implementation nor in the flutter go embedder. Is there anyway we can renew interest in this subject? I'm not particularly great at leak hunting myself.

Edit: One thing I forgot to mention is that memstat appears to say that the leak isn't happening on the golang side, and I've made sure that my Mats are closed after usage. This could point to a leak in the flutter texture implementation, but I don't see it.

@pchampio
Copy link
Member

pchampio commented Mar 5, 2020

@j4qfrost I'll take a look at this once I have more time.
It's awesome to see someone working on this subject!

@j4qfrost
Copy link

Bump. Is there anything I can do to get better at tracking down the leaks?

@pchampio
Copy link
Member

I don't time at the moment, I'm very sorry but I can't help.
To track the memory leaks we can use valgrind, but it will interfere with the C-based engine.

@lmx01
Copy link

lmx01 commented Mar 24, 2020

I use this in Mac.But I got error like these:

(This is taking an unexpectedly long time.) ⢿go-flutter/plugins/video_player WARNING MethodCall to ' setLooping ' isn't supported by the Golang video_player

Can U help me?Thanks.

@j4qfrost
Copy link

j4qfrost commented Apr 19, 2020

Edit: This isn't it. Handled here:

opengl.DeleteTextures(1, &texture.texture)

@pchampio I think I may have found a solution. I'm ashamed I hadn't thought of it earlier. The guys over at flutter-rs got around to fixing the memory leak issue by calling the destruction_callback https://github.com/flutter-rs/flutter-rs/blob/696d4b1ecce501e061523d01d8476280f88f3d2e/flutter-engine/src/texture_registry.rs#L122. The downside to this is that I ran into high CPU usage. I am not sure if that's due to the constant frequent destruction, but that's the only thing I can think of.

I'll see if I can get something working.

@pchampio
Copy link
Member

pchampio commented Apr 20, 2020

@j4qfrost
I'm not sure why they call this callback manually.
ALSO,
I've removed this the destruction_callback from go-flutter because it wasn't working, and I didn't really know what to do with it..
Seeing flutter-rs manually collecting the frame does indicate that I missed something.
Here is the destruction_callback commit:
3f8aa3a#diff-be67eb30388f811db5d0770a2f2c0a8aR138-R141
With this, I'll have more pointer to easily help us^^

@j4qfrost
Copy link

I'm not quite sure either. Maybe it's because The allocation for an OpenGL texture happens first and this is to ensure that the texture gets destroyed in case registering on the engine doesn't take place.

What I seem to be observing with the memory leak seems to be in line with some framebuffer not clearing. When I ran the video player examples under flutter-rs some months ago, I didn't have the same memory leak issues, but I did have insane CPU usage, and after looking at it for a bit I think the reason is that at each interval, the actually replace the texture handler rather than push in a new PixelBuffer, https://github.com/flutter-rs/flutter-video-plugin/blob/99b6133b8cdee38432d45c762c12318818ff1ad7/src/video.rs#L116

post_rgba calls post_internal which calls destruction_callback which calls glDeleteTextures, and this happens each time there's a new frame.

I'll reach out to the flutter-rs guys tomorrow and ask about this. Last I checked their development has slowed. csnewman is still working on it.

@pchampio
Copy link
Member

last time I checked flutter-rs I saw those 2 commits:

The high CPU usage might of come from their event loop, not their texture ABI.

On the go-flutter side we are still in the process of merging: #390
and the way we handle tasks differ from flutter-rs. I thinks we shouldn't encounter the same high CPU usage.

@pchampio
Copy link
Member

Quoting from csnewman (gitter.im):

I've managed to track down the poor performance issues, they were being caused by the render_task_runner, with this unset (we can implement a proper runner at some point), we now have equal performance to the other platforms. This should improve video playback and the likes

@j4qfrost
Copy link

So it would be fine to throw away the texture at each redraw? I'm also kind of confused about what the purpose of the destruction_callback is. Is it actually called within the flutter api if it gets set or is it just there for convenience?

@pchampio
Copy link
Member

Looking a bit deeper at the flutter-rs code, it seems they are Creating a new texture on every new frame. This isn't what we do, we are reusing the same texture, instead of creating/deleting on each frame.

FWI: the go-flutter implementation was based of flutter/engine#9822

@pchampio
Copy link
Member

Also another FWI, @befovy has started to port his video player to go-flutter, I think he stop because of #311

https://github.com/befovy/fijkplayer

@j4qfrost
Copy link

Yeah, I recognized that go-flutter and flutter-rs differed in that respect. I was considering deleting the texture at each frame to see if that solved the memory leak but wasn't quite sure how to do that, so I held off until I got a response.

I actually was able to somewhat successfully use webcloudrtc's branch, but I stopped when I realized how much of a pain working with Makefiles would be moving forward. By then I had a stuttering demo working, and it was also a pain to keep my flutter install at the right version for everything to work correctly.

@j4qfrost
Copy link

Also forgot to mention that I can't use valgrind on my machine due to some paging issues with mac. I haven't gotten my linux machine set up yet.

@pchampio
Copy link
Member

Even if you use valgrind, it's going to fail. Since the engine is written itself in C, the output will just be a bunch of unrelated mess.

@MattNguyen
Copy link

We began our own ffmpeg-based implementation as we needed to get video and audio to work:

https://github.com/telefuel/video_player_testbed

Currently we’re stuck on getting the audio and video to sync, most likely the result of some missing ffmpeg incantations or worst case some compatibility issues with the hardware.

We also have an open bounty to get this resolved.

@pchampio @j4qfrost any thoughts on our implementation?

Having a functioning video/audio player is critical for us and other applications. We’d be happy to support this effort.

Cc @kiasaki

@pchampio
Copy link
Member

@MattNguyen this is so cool!
I've quickly glance through you implementation, it's much more cleaner than what I've previously done.

I'm always surprised on how the community is using go-flutter ❤️

I currently don't have much time to work on such plugin, I respect the time and money you put into this.
(But, I'll also like to point-out that other embedder exist. And in the future, they'll certainly have a working video_player plugin.)

@hamidabdulmalik
Copy link

@MattNguyen Where are we on this Video Player thing man. Anything new yet?

@MattNguyen
Copy link

@MattNguyen Where are we on this Video Player thing man. Anything new yet?

We've since moved on from the project, and was unable to progress on the video player. The issue is certainly related to some ffmpeg incantations that we're not familiar with. Hopefully someone can take over the work and solve the issue.

@ablockhead
Copy link

我打包出的 windows桌面应用字体有点问题 请问我如何修复它

@Leadrive
Copy link

Leadrive commented Jan 7, 2021

@ablockhead 能贴个windows的例子吗?正在弄这个,我还没搞通。

@Leadrive
Copy link

the flutter video_player plugin change a lot.
this version does not run with it.
Please update.

I use the version v0.10.9+2 to test in Windows 10, only the tests-sample.mp4(https://github.com/3d0c/gmf/blob/master/examples/tests-sample.mp4) can play, the other mp4 report Resource temporarily unavailable error.

@Leadrive
Copy link

Leadrive commented Feb 2, 2021

flutter/engine#20714
flutter/engine#19405
maybe the texture supported on Windows and Linux.

@pchampio
Copy link
Member

pchampio commented Feb 2, 2021

@Leadrive this is related to the official linux embedder.
GoFlutter is another implementation of the flutter embedding API (read our readme if you are lost).
Differences between both project are listed here: #191 (comment)

The PR you referenced above have nothing to do with go-flutter.

In this un-official implementation, we have merge texture back in Aug 2019 in #217

We need contributor to implement our go-flutter compatible version of the videoPlayer. Some work has already been done: https://github.com/telefuel/video_player_testbed

https://github.com/go-flutter-desktop/examples/tree/master/texture_tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin Issue about an existing or possible plugin wontfix This will not be worked on
Development

No branches or pull requests

9 participants