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

Use media kit as the default video playback for windows #29

Merged
merged 11 commits into from
Jan 21, 2023

Conversation

bdlukaa
Copy link
Collaborator

@bdlukaa bdlukaa commented Jan 16, 2023

I could experience gains of 30% to 40% in performance by using media_kit on Windows

Features

  • Play from url
  • Play from file
  • Update volume
  • Update speed
  • Seeking

Screenshots

image


There seems to be a minor flickering when reordering the views in the multiple view

@bdlukaa bdlukaa marked this pull request as ready for review January 17, 2023 17:20
@bdlukaa bdlukaa marked this pull request as draft January 17, 2023 19:33
@bdlukaa
Copy link
Collaborator Author

bdlukaa commented Jan 17, 2023

I will keep this as a draft because it's causing crashes to the app. media_kit is not stable enough to give it a try for now

¹ For some reason, it seems it's blocking the UI thread, so app behaves extremely slow. Sometimes, it's unusable
² When navigating to another screens, the VideoController object is kept alive (so that is a gapless playback when coming back to the grid). This seems to be causing crashes since the Video object is not into view

cc @alexmercerind

@alexmercerind
Copy link
Member

alexmercerind commented Jan 17, 2023

For some reason, it seems it's blocking the UI thread, so app behaves extremely slow.

The video rendering does occur on render thread. A "hit" due to multiple videos will definitely be there (should improve in release mode). If there are no videos in the view, there should be no frame drops/delays etc.


Crash:

There shouldn't be any crashes on Windows. I & other users have confirmed the recent fix which addressed last few race(s). There are a number of cases/situations in the test application where we haven't been able to see any crash since latest fixes.

As for any crash, let's see what further feedback I get. Personally, I'm unable to.

Performance:

There isn't any scope of improvement in terms of performance AFAIK. In comparison to package:dart_vlc, the performance offered by package:media_kit is already very-high. Everything is being rendered off the GPU.

@bdlukaa bdlukaa marked this pull request as ready for review January 20, 2023 21:46
@curtishall
Copy link
Member

@alexmercerind I know you are busy, when you have time can you review this PR? It's blocking #31

Copy link
Member

@alexmercerind alexmercerind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (+ recommendations) !

You can try use the current package:media_kit branch that I'm working on.

https://github.com/alexmercerind/media_kit/tree/perf/win32-copy-separate-id3d11texture2d

The level of performance should be further improved as compared to main branch. There are few more performance improvements which I'd like to make, however I won't be able to get this branch/PR over the line before this month (though it's usable in current state).


As far as media-kit/media-kit#28 is concerned, I don't think it will ever be. You have to create your own solution here. Primarily because libmpv does not offer such functionality out-of-the-box & implementing one from scratch will be:

  • Redundant.
  • Requiring more maintenance cost.
  • Of different level of abstraction than that of package:media_kit (if custom implementation is made).

100% of implementation of package:media_kit is in pure Dart, only video rendering is platforms specific C/C++.
You're free to play around.


There seems to be a minor flickering when reordering the views in the multiple view.

I see the last commit with ValueKey, that should improve IG. I'm not sure however.


One final recommendation I'd like to give is that you can try to specify width & height parameters in the VideoController.create method. It will create a less sized D3D Texture / EGLSurface (and thus squeeze the performance).

Especially in grid layouts, where video won't be visible in large sizes, a fixed width & height texture will work & take less resources. However, when viewing same camera on larger screen, a different VideoController without fixed width & height can be used (& disposed upon exit).

@bdlukaa
Copy link
Collaborator Author

bdlukaa commented Jan 21, 2023

One final recommendation I'd like to give is that you can try to specify width & height parameters in the VideoController.create method. It will create a less sized D3D Texture / EGLSurface (and thus squeeze the performance).

Indeed. By doing that, I got a ~15% performance improvement

@bdlukaa bdlukaa merged commit dbce6fa into bluecherrydvr:main Jan 21, 2023
@bdlukaa bdlukaa deleted the media_kit branch January 21, 2023 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants