cdgriffith / FastFlix

FastFlix is a free GUI for H.264, HEVC and AV1 hardware and software encoding!
https://fastflix.org/
MIT License
1.13k stars 55 forks source link

Pause and Resume encodes #84

Closed loungebob closed 2 years ago

loungebob commented 3 years ago

Since x/h265 takes forever to encode (at least on my machine), a pause and resume function would be soooo cool. I urgently need to reboot (yeah windows) and cant cause the current encode is 12 hours in and still 5 hours away from being finished.

Is that even possible? Saving whateverdata and then resuming from it?

I dont think I can add a label but if I could, this would be a feature request.

cdgriffith commented 3 years ago

So I know FFmpeg itself can be paused / resumed while the process is still running. (On windows using the Pause/Break key, the using Enter to start it again.) That is something I think would be handy to add and will look into it.

To be able to halt it and resume after a restart is a whole other can of worms that I don't think I could come up with a clean automated process for.

The best "solution" I can think of is stopping the process full on where it is, figuring out where it ended (duration), do another encode for the rest of the film and add them together. But with how some audio codecs and video codes work it may not get both to line up as desired without a lot of tweaking. And that's assuming it was a 'clean' ending, whereas will probably need to do some work fixing the first portion so it can be added to smoothly.

Somewhat related, in 3.1.0 I just added a call to windows that tells it "Hey, I'm running, don't go to sleep on me." which might also hold off forced reboots, but I do not know. I have been running into interrupts from Windows updates myself and want to stop that from FastFlix itself.

loungebob commented 3 years ago

well a pause/resume function in the current windows session would be very nice indeed.

I have zero programming knowledge so in my mind it was something like saving a snapshot of the current state like windows hybernation or I assumed how dockers and vm’s work and then loading this snapshot after a reboot and resume like there was no break inbetween the 2 windows sessions. a little like the matrix, you know lol

but like most things in life, this is probably a far too simplistic view of it.

cdgriffith commented 3 years ago

You actually are correct that you can accomplish it with VMs and they have saved state!

I can't wrap it up with a bow as part of FastFlix sadly, but if this is a common occurrence for your situation that you need to frequently stop encodings, could start up a windows VM and suspend it when needed. (For safety I would also pause the FFmpeg command itself running inside of it first.)

cdgriffith commented 3 years ago

Added in 3.2.0

loungebob commented 3 years ago

Very cool! Thanks mate. Also, I’ll try the VM way for my reboot needs.

loungebob commented 3 years ago

One thing I noticed though, a paused process still used 15% CPU cycles (and showed as paused in task manager). Aint that a tad high...what’s it doing using that much power in a paused state?

cdgriffith commented 3 years ago

So right now it is being paused with a utility called psutil that works slightly different across operating sytems, but does work across all OSes. I honestly do not know what is actually causing that spike, but don't have any control over it.

Ideally I would like to be able to send a singnal to FFmpeg itself to use it's built in pause ability, but I haven't found a way to do that with Python yet. (Aka send the "Break" signal to a subprocess.)

cdgriffith commented 2 years ago

Re-opening feature request as this functionality was removed due to errors it was causing at the time.

cdgriffith commented 2 years ago

Must be going crazy because that feature is and has been there for a while. Have at least added a warning message now for VCE / NVENC users so calling that "done" for now unless something else pops up.