RandomEngy / VidCoder

A Blu-ray, DVD and video file transcoder for Windows.
http://vidcoder.net
GNU General Public License v2.0
668 stars 42 forks source link

Idle priority for worker process #1186

Closed FCrane closed 8 months ago

FCrane commented 8 months ago

Feature details

Hi!

It would be nice if the priority of the worker process could be set to "idle", not just "low", so that all other processes would not be slowed down and encoding could really run in background only using idle CPU time.

It's done with the "SetPriorityClass" API function and IDLE_PRIORITY_CLASS parameter.

Thanks!

RandomEngy commented 8 months ago

Do you have processes running at Low priority that you need to not be slowed down?

FCrane commented 8 months ago

Probably, because when the encoding process is running, the whole system gets less responsive and sluggish. Especially everything with disk access of graphics gets slow - e.g. 4K video playback stutters, etc. I'm hoping that setting the priority to idle could fix that, so that if anything else needs the CPU, encoding is halted. Not sure if that would solve the issue, but theoretically idle priority should be better than low for this case...

PS: maybe it's possible to add some way to remotely pause VidCoder? This way I could easily send it a pause command whenever I need full CPU power and resume it afterwards. E.g. A command line option, a custom message, etc. Currently, I need to click "Pause" manually (e.g. when watching a short 4K clip) and often forget resuming it again since it mostly runs minimized...

RandomEngy commented 8 months ago

https://learn.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities

The system assigns time slices in a round-robin fashion to all threads with the highest priority. If none of these threads are ready to run, the system assigns time slices in a round-robin fashion to all threads with the next highest priority.

So moving something from Low to Idle priority would only help processes that were marked Low.

There is a feature in VidCoder that can automatically pause when it sees a certain process running. So you could put your media player in the list, and VidCoder would pause when it starts up and resume when it closes.

FCrane commented 8 months ago

Thanks - the process pause feature does help! However, I'd like VidCoder to pause only when 4K videos are played, not for smaller resolutions. This could only be done with a possibility to remotely pause and resume VidCoder.

BTW: the (very long) process list should be sorted alphabetically so that I can find the respective process easier... Or some kind of filter...

Still I think setting a process priority to idle could help improving system responsiveness - maybe worth a try?

RandomEngy commented 8 months ago

Based on documented behavior, I don't believe it has any chance of helping your situation. Media players, apps and games pretty much never run on Low priority.

FCrane commented 8 months ago

The process pausing suddenly has stopped working! Even if I remove the video player from the process list in VidCoder and re-add it, the encoding will still not be paused. It used to work a few times, but not it doesn't anymore. What's going on?

Also, it'd be much better if the process list simply was an edit box where I can enter parts of the process path instead of just the process name! This way, I could e.g. quickly disable the pausing by just adding any extra character to the program name, etc. Removing and re-adding a process would also be a simple cut & paste operation instead of the tedious searching in a long unsorted list of processes...

RandomEngy commented 8 months ago

You can check the "General" log tab and it should have messages about the auto-pause behavior. If you have that log, and the name entered in the auto-pause list, and the process name, I might be able to tell you something more about what's happening.

FCrane commented 8 months ago

When it's working, the general log contains lines like:

VC [08:55:15] Automatically pausing, process detected: IsoPlayer VC [08:56:25] Automatically resuming, processes are gone.

When it's not working, there are no lines containing anything about process detection, pausing, resuming, etc.

It did start to work again after restarting VidCoder, so it seems something that can "break" during runtime and will be restored after a restart.

Please do consider my suggestion for choosing and entering the processes, because the long unsorted list of processes is uncomfortable to work with - especially if I need to frequently add or remove my player (for HD playback, VidCoder should run, for UHD playback, it should not). A checkbox to quickly enable / disable the process pausing feature would also help a lot (like with battery and disk space)!

Still ideally, there would be a way to remotely pause and unpause VidCoder from another app (e.g. by command line parameter, which should be easy to implement).

Thanks!

RandomEngy commented 8 months ago

In 9.12 I added a couple features:

FCrane commented 8 months ago

Great!!! Thank you! Am I correct that this is not working with the portable version? Also, if I run the GUI version, will the command line pause and resume this as well? I'.ve never tried VidCoderCLI because I'm using the protable version...

RandomEngy commented 8 months ago

You are correct! The automation host isn't started up in the Portable version so even if you found the temporary copy of VidCoderCLI.exe it wouldn't successfully connect to the main process.

It works on the installer version. (And the updates there are painless, as well)

JNavas2 commented 2 months ago

PMJI: