PeerTube icon indicating copy to clipboard operation
PeerTube copied to clipboard

Show estimated video transcoding time

Open Nutomic opened this issue 7 years ago • 7 comments

I'm getting a lot of questions by uploaders that want to know the time until an upload of theirs is transcoded. Unfortunately, this is almost impossible to estimate, because there are a lot of factors, like:

  • video length and bitrate
  • server CPU speed
  • enabled resolutions
  • other videos in the queue

Instead, it would be nice if Peertube could display the estimated transcoding time, probably on the upload screen.

It would also make sense to show the total length of the transcoding queue separately, and inform the admin if it is unusually long.

Nutomic avatar Jul 12 '18 02:07 Nutomic

During encoding FFMpeg dynamically reports:

frame= 1371 fps= 33 q=28.0 size=   22266kB time=00:00:54.12 bitrate=2815.8kbits/s speed=1.37x

From here there is number of ways to evaluate ETA.

I see the most robust, simple and flexible is:

time here is a real-time playback timestamp in the video. So it shows us real current encoding position in the video, relatively to the total length of the video.

  1. Get the stream=duration (would be aka totalTime):
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 <source_file>  

We are getting duration of playback reported by container, it (container) solves the case. Mingling with streams would tend to get too complex. There is v:0 stream in 97% cases, but in others, it can be v:1, or there can be any number: v:n (VR, 3-angle camera video). Or if we support podcasts, - they often have no video stream, than we must... Streams often also have time offsets in any direction...

So we just get duration of playback from authoritative source - container, and that is it.

It would return number in seconds: 596.458333 For simplicity let's round it: totalTime = round(596.458333) = 596

  1. Current encoding position:

During encoding we are gathering that time=... through the regexp, rounding it, and converting it into seconds. time = 00*3600 + 00*60 + 54 + (round 0.12) = 54

  1. Calculation Let's calculate how much of playback timeline is left to encode. And divide that number by value of encode to playback speed rate that FFMpeg reports:
ETA = round ((totalTime - time)/speed) = round ((596 - 54)/1.37) = round (395.62043795620434) = 396 seconds.

It gives us accurate estimation, while all this works for any types of scenarios.


I propose this time-based variant and not others, because if we would go frame numbers, FPS route - there are plethora of corner cases and variants that need be accounted then, and ETA code over would become a mess.

Container&Time-based variant is universal for all cases.

Anton-Latukha avatar Jul 12 '18 11:07 Anton-Latukha

At best we can only tell the position in the transcoding queue of a video, and the time left to transcode once transcoding.

Your users will still have a very vague notion of when their video will be transcoded…

rigelk avatar Jul 12 '18 11:07 rigelk

As pointed out on IRC, we can easily access the progress of an active job through the API provided by fluent-ffmpeg: http://fluent-ffmpeg.github.io/index.html#setting-event-handlers

rigelk avatar Jul 12 '18 17:07 rigelk

Admins can now see transcoding progress percentage in job list: https://github.com/Chocobozzz/PeerTube/commit/3b01f4c0ac764ecb70efaadfd939ca868c28769c

Chocobozzz avatar Jan 21 '21 13:01 Chocobozzz

Admins can now see transcoding progress percentage in job list: 3b01f4c

Why not make the percent visible to the uploader? It would them to know on their side the progress of their video.

Kinuseka avatar Nov 21 '22 10:11 Kinuseka

Why not make the percent visible to the uploader?

Question goes unanswered.

luzpaz avatar Dec 11 '23 11:12 luzpaz

Can we get the percent visible to the uploader? Or even better, an estimated time to completion?

vid-bin avatar Feb 20 '24 04:02 vid-bin