Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
9th June 2018, 17:52 | #44 | Link | |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Quote:
MT is working. I'm calling SetThreadCount(8) send 8 frame requests, and each time a frame is done I add a new one into the queue. Now the CPU still runs only at 40%. When I call GetFrameAsync on my class, it returns the frames in the same order they were requested so that's working very well. |
|
9th June 2018, 21:40 | #45 | Link |
unsigned int
Join Date: Oct 2012
Location: 🇪🇺
Posts: 760
|
Is your script complex enough to fully use the CPU?
There is no guarantee you will receive the frames in order. You have to handle reordering them.
__________________
Buy me a "coffee" and/or hire me to write code! |
10th June 2018, 00:57 | #46 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Code is already written to reorder them. My VsOutput class raises 2 events: FrameDone (when frame is processed, to insert new request into the queue) and FrameReady (for display, guaranteed to be in right order). That's working well.
I see that if I skip display code, it runs MUCH faster; but still, it only runs at 40% CPU. There's only FFM2 in the script so far, maybe it's not designed to run faster than that. |
12th June 2018, 20:42 | #49 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Looking to replace Avisynth with VapourSynth in my Yin Media Encoder that goes with the Natural Grounding Player for video processing, and use Avisynth only for audio processing.
Could also add nice features like previewing various versions of a script side-by-side by switching tabs, zooming in, and seeking/scrolling simultaneously in all tabs. This would be better than simply opening up a script in MPC-HC. I'm also switching into using MPV via dll instead of Windows Media Player for audio and video playback; working on an UI right now because all these alternative media players have no decent UI.
__________________
FrameRateConverter | AvisynthShader | AvsFilterNet | Natural Grounding Player with Yin Media Encoder, 432hz Player, Powerliminals Player and Audio Video Muxer Last edited by MysteryX; 12th June 2018 at 20:53. |
13th June 2018, 15:23 | #51 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
AFAIK VapourSynth doesn't have any audio support. You can "hack" it into holding audio data but that's about it.
I'm using it to tune 440hz audio to 432hz audio, and then open those scripts in MPC-HC to tune video audios in real-time. I haven't seen any such feature in VapourSynth. |
19th June 2018, 18:25 | #52 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
OK I got a nice media player UI with seek bar, play/pause/stop. Was working around some multi-threading memory leak issues, which also caused clearOutput to crash. Now that's fine.
Now I'm having issues with vsscript_freeScript freezing the app when pressing Stop. Code:
if (output != null) { lock (outputLock) { if (output != null) { output.ClearQueue(null); output.Dispose(); // Good scriptApi.Dispose(); // Freeze scriptApi = null; } } } // output public void Dispose() { VsInvoke.vsscript_clearOutput(apiPtr, nodeIndex); Api.freeNode(nodePtr); } // scriptApi public void Dispose() { VsInvoke.vsscript_freeScript(scriptPtr); } Edit: It works if I stop while on Pause, so it has to do with pending frame requests. However, even waiting until the processing queue is empty before calling Dispose doesn't help. If I'm on Pause, request one frame, display it, then click Stop to dispose of objects, everything is fine. If I have 1 thread while playing, click Stop, wait for that 1 request to callback, free the frame, then dispose of objects, it freezes on vsscript_freeScript. Furthermore, if I click Pause then Stop, it works. If I call this before Stop (which should have the same action), it freezes. Code:
Paused = true; Thread.Sleep(500); Stop();
__________________
FrameRateConverter | AvisynthShader | AvsFilterNet | Natural Grounding Player with Yin Media Encoder, 432hz Player, Powerliminals Player and Audio Video Muxer Last edited by MysteryX; 19th June 2018 at 20:17. |
19th June 2018, 23:54 | #53 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
I placed debug code on GetFrameAsync and on ReleaseFrame to see whether there's an unreleased frame that slipped by.
Every frame is released by the time I dispose of the script. I guess there's something else I'm missing then. What could it be? |
20th June 2018, 04:44 | #54 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
I've uploaded the code for if anyone has an idea.
It is mostly between VsMediaPlayerHost.Stop https://github.com/mysteryx93/Vapour...erHost.cs#L249 and VsOutput.GetFrameAsync_Callback https://github.com/mysteryx93/Vapour...Output.cs#L119 |
20th June 2018, 13:32 | #55 | Link |
Excessively jovial fellow
Join Date: Jun 2004
Location: rude
Posts: 1,100
|
I may be missing something, but in Stop() you call ClearQueueWait(), which seems to be intended to clear the frame request queue and free all requested frames (since that's what ClearQueue does), but that method doesn't seem to actually do anything...? The setter for Pause does call ClearOutput, so that may explain things.
|
20th June 2018, 17:44 | #56 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
I can clear the processing queue but not all callbacks are triggered yet so there's not much I can do within Stop. I have to wait for callbacks to be triggered.
ClearQueue flushes the queue right away and subsequent callbacks are ignored because they're not found in the queue. Good for seeking. However, in the case of stop, this doesn't allow to know when all callbacks are done and frames are freed. As a work-around, I created a 2nd function that simply tells to stop refilling the queue and notify when it's empty. (perhaps this might cause some issue if I seek and then stop immediately after, in some rare cases? Seek flushes 8 requests and puts 8 new requests in. Stop waits for those 8 new requests to be done. In a weird case where 1 flushed frame is returned after the 8 new frames are done, this could cause an issue, but that's very unlikely) |
20th June 2018, 19:29 | #58 | Link | ||
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
Quote:
Stop while playing "should" work as well, but it fails even if I call Pause in-code first. Quote:
|
||
22nd June 2018, 05:04 | #60 | Link |
Soul Architect
Join Date: Apr 2014
Posts: 2,559
|
How do I get Vapoursynth's installation path to find its DLL? From the registry I suppose?
Actually it seems I don't even need to specify the path, if I trust Windows will load the right files.
__________________
FrameRateConverter | AvisynthShader | AvsFilterNet | Natural Grounding Player with Yin Media Encoder, 432hz Player, Powerliminals Player and Audio Video Muxer Last edited by MysteryX; 22nd June 2018 at 05:35. |
Thread Tools | Search this Thread |
Display Modes | |
|
|