Comments (11)
Should be fixed in #90.
paint_first_frame.mp4
from media-kit.
It's not.
from media-kit.
@canewsin I am calling jump on the player immediately after opening the video file to achieve this on the Windows platform. It works in my use case - not sure that it's best practices.
from media-kit.
Best practice is to serve a thumbnail from the backend & use it as a placeholder before video starts to play.
I'll be able to tell better about feasibility of this around the end of this month (& if possible, get it over the line myself).
I'm engaged with few things these days, so unable to make any statements.
from media-kit.
I did exactly that:-
- Showing the first frame during entry slide-in up until
await player.play()
completes - Showing the last frame of the video after video completion (
streams.isCompleted
) up until slide-out completes
However, as shown in the video, I am having 2 problems
- The player takes about 1 to 2 seconds after
await player.play()
to actually start playing the video. You can see the black screen in between the first frame and play, in the screencast below. - After completing the video, the player shows the first frame, instead of pausing on the last frame. You can see the brief flicker to the first frame on completion of the video below.
Here's the screencast. The slide animation is a 3 second one, during which the outgoing one displays the last frame of the video (separately held screenshot in jpg format, not displayed via mediaKit) and the incoming one displays the first frame until the video starts.
Screencast.from.26-03-23.09.37.14.PM.IST.webm
from media-kit.
If someone wants to take a look themselves (I aim for this in post this release):
You only need to play around the logic within Dart (package:media_kit) & tweak how file etc. are loaded. Very simple logic. This has nothing to do within platform specific video embedding code.
from media-kit.
I optimized it for audio applications initially. Now it needs to be updated to meet video rendering requirements i.e. no missed frames, initial frame draw etc. etc. Specifically here (how I've abstracted internal libmpv playlist management to be more friendly within Player
):
Project is still at early stage (only first version out). For normal applications, which just want to play video in a performant & stable way, this is still good. Further tweaks & optimizations here & there are left.
https://github.com/alexmercerind/media_kit/blob/03d8a702d5c0600e94548fd68a6b71c1485a0e49/media_kit/lib/src/libmpv/player.dart#L138-L165
https://github.com/alexmercerind/media_kit/blob/03d8a702d5c0600e94548fd68a6b71c1485a0e49/media_kit/lib/src/libmpv/player.dart#L88-L135
from media-kit.
I was tweaking around with the player code. As you have mentioned, it gets slightly better when the width & height are specified during initialization - the black flicker that occurs before playing (as seen in my screencast) got reduced to a moment's flicker.
videoController = await VideoController.create(player.handle, width: videoResolutionX, height: videoResolutionY);
Another hack - initialize the player with play: true. Then, pause & seek to zero. This gets the video fully ready to play. On next call to play, the video gets unpaused which takes a lot less time.
await player.open(mk.Playlist(
[
mk.Media('asset://assets/${widget.itemVideo.filename}')
]
), play: true, evictCache: false);
await player.pause();
await player.seek(Duration.zero);
Now there's zero flicker on start. Yet to test it thoroughly though. That's about the first problem. Still facing the second problem - on completion of the playlist, the player rests on the first frame of the video instead of blank / last frame. Let me tweak around and post an update on that problem.
It's pretty impressive to see what media_kit can do while barely at 1.0 👍
from media-kit.
media_kit is not 1.0.0, it's 0.0.1! Expect breaking changes & massive API refinements (like next update) before 1.0.0.
Another hack - initialize the player with play: true. Then, pause & seek to zero. This gets the video fully ready to play. On next call to play, the video gets un-paused which takes a lot less time.
Yes!
I was referring to these minor workarounds & refinements (or "hacks" as you said). The internal Dart sided logic needs to be changed to fit every possible case. Currently AFAIK video is redundantly reloaded due to jump
. I'll optimize the things to their best.
evictCache
does nothing but hold extras
that you specify in Media
constructor.
from media-kit.
Yes... 0.0.1 😄 & can play 5 hd playlists in parallel
Let me fool around with the code a bit. Currently trying to plug the memory leak in linux.
from media-kit.
Hi!
It's fixed in latest update: media_kit: ^0.0.2.
macOS & iOS support. A large number of stability improvements, new features & bug-fixes.
Next update will bring Android & Web support.
Thanks!
from media-kit.
Related Issues (20)
- how to play ftp link video HOT 2
- Subtitle names are not available
- [Linux] GPU Acceleration HOT 6
- Use interactive viewer HOT 1
- In Flutter web, google chrome (not mobile's browser, desktop browser) does not play video HOT 5
- [HLS] Seek does not work on macos & android HOT 7
- Audio does not play again after setting new Audio track after calling player.stop() HOT 12
- add PlayingState ? HOT 1
- [Crash][macOS] Abort Signal on macOS HOT 5
- Non-C locale detected error HOT 1
- [Improvement advice] Performance update
- Android background playback.
- The vertical screen is full screen, and the subtitles are in the wrong position.
- [android] how to enable libass on Android? HOT 14
- No video, only sound on Android
- [Android] Video is completely black on real device HOT 15
- How to setup upscaling for video?
- VideoController scale, width, and height not being set
- linker command failed with exit code 1
- [Help] key.currentState never worked
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from media-kit.