Get a time estimate while waiting for your video
veltman opened this issue · 3 comments
Current status updates tell you what stage the rendering is at and % progress, but it would be nice to get a full waiting time estimate, especially if you're in a queue with jobs in front of you. This would entail some formula for estimated completion time, which would require knowing the duration before a job has started, so we'd probably have to send a duration estimate from the browser. Then we could multiply the duration and framerate by some conservative per-frame estimate.
ffmpeg has a -progress URL
option, where progress info is HTTP POST-ed (chunked), that could feed into express and relayed further to the user
The FFmpeg processing time is only a small fraction of the total time, the main issue is drawing the frames. The steps to an estimate would basically be:
- Include a
selectedDuration
value in each job when it's submitted. - Keep a moving average of how long each step takes per second of length.
- Use those per-second benchmarks to estimate how long each step a job of X seconds will take.
- To compute the ETA of a job, add up the estimated time of the remaining steps for in-progress jobs (if queued), plus the estimated time of the remaining steps for the job itself.
Steps 2 and 3 could be skipped in favor of a rough estimate based on system stats detected by os.cpus()
and os.totalmem()
.
Yup, I'm digging into FFmpeg progress for other projects, the HTTP chunked POST it can make is messy to listen to, looking now at https://github.com/eugeneware/ffmpeg-progress-stream