Comments (1)
Hey @luthfiampas
You are on the right track. What is the best way to 'trigger' an event to present the frame... There is a lot of space to answer this question. How am I doing it in Flyleaf...
I've the Screamer thread for this reason. It is similar to the one that you have above with one exception.... It waits to fire both video/audio/subs in a single thread.... and most importantly it doesn't spins until the time comes... but it sleeps (min time required to present video frame, or audio/subs frame). Thread.Sleep will calm down the CPU and will allow other threads to run. What is the best way? Not sure, but if you look at the most common open source players out there you will see similarities.
Let's take ffplay as another reference:
You will see the read_thread that it does what my demuxer/decoder threads doing. Then you will see refresh_loop_wait_event / video_refresh / video_display which is the similar with my Screamer and PresentFrame. refresh_loop_wait_event is mainly what you are asking, which is uses av_usleep((int64_t)(remaining_time * 1000000.0)); which is defined here
In .NET/windows and with SharpDX I've decided currently to use that way. Might have space for better performance though. It's very important when you write a player to be accurate with the FPS, so you can't avoid a) TimeBeginPeriod(1) to ensure that Thread.Sleep(1) will sleep always 1ms and not more than that... and b) to 'spin/thread.sleep(until pts)' to present the frame accurately. One more consideration on this 'loop' is to ensure that you don't waste a lot of time in every loop so you can present also next frames in time. That's the reason you need to have a solution to drop frames in a case like that. (Imagine if you demux/decode/present frames within the same context/thread, you are probably going to come up with a lot of dropped frames)
Feel free to ask any more clarifications ;)
from flyleaf.
Related Issues (20)
- I would like to print a specific part of the image by blurring it, is this possible? HOT 1
- About ShowFramePrev HOT 2
- Overlaps and Refresh in SharedOverlay
- Stream synchronization issue HOT 7
- Possible handle leak when repeatedly create/play/stop/dispose flyleaf players HOT 13
- Open stream at current position HOT 6
- FlyleafSharedOverlay in wpf ViewBox HOT 3
- Renderer: Level/Gamma Support HOT 4
- crash by set curtime HOT 2
- SharedOverlay as the Visual of a VisualBrush
- Get FlyleafSharedOverlay DetachedContent as Visual HOT 9
- Decoder (Subtitles): Bitmap Support HOT 1
- Issues of brightness control HOT 1
- [New feature requests]Added multi-threading support for M3U8 HOT 3
- Demuxer: Blu-Ray Support HOT 8
- Subtitles seeking support HOT 2
- Memory Leakage HOT 11
- current subtitle disappear when resuming from pause HOT 1
- WPF FlyleafHost: Load/Unload should be symmetrical HOT 1
- Deadlock in Pause() HOT 3
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 flyleaf.