Showing in-video visual progress bar with FFMPEG?
Asked Answered
D

2

3

As OBS Studio lacks a visual indicator to show how far a video has progressed (and when you need to advance to the next scene), I was wondering if there is a command-line option (or solution) to get FFMPEG to re-encode the video and show a progress bar at the bottom of the video that shows how long the video has been playing so far.

Is there such a feature?

Deirdre answered 20/7, 2020 at 6:49 Comment(0)
D
13

Here's a simple 3 second example using an animated overlay:

progress bar example

ffmpeg -i input.mp4 -filter_complex "color=c=red:s=1280x10[bar];[0][bar]overlay=-w+(w/10)*t:H-h:shortest=1" -c:a copy output.mp4

What you will have to change:

  • In the color filter I used 1280 as an example to match the width of input.mp4. You can use ffprobe to get the width or the scale2ref filter to resize to match input.mp4.

  • In the overlay filter I used 10 as an example for the total duration in seconds of input.mp4. You can use ffprobe to get the duration.

Draughtboard answered 20/7, 2020 at 20:47 Comment(7)
Is it possible with ffmpeg to do this around the video like it is popilr now on fb or ig? So instead line on the bottom progress would be arond whole video from right to left in the beginning.Mascia
@DejanMilosevic Do you have a link to a video that does what you want?Draughtboard
I will try to find but it is actually same as this but red line goes all around video.Mascia
Is it possible to add a background to this filter? #71246386Robbi
Thanks! I use this method to show the progress when encoding a video, including ffprobe to get width, height and duration and include these values in the ffmpeg command: https://mcmap.net/q/239371/-can-ffmpeg-show-a-progress-barHundredth
Can you tell me what "H-h" means? I don't find documentation of it...Hundredth
Regarding getting "the width" with ffprobe, see here for assigning that to a variable on Windows' Batch.Cailean
C
1

Here I provide elaboration for the accepted answer.

Along the way, I also answer Mario Mey's question of what "H-h" means.


Visualization:

visualization

Explanation:

color[bar] and [bar]overlay means the output bar from color goes into the same-named input of overlay. [0] by default refers to the input file, here given into the overlay filter.

ffmpeg-filters 16.11 color (color c; size s)

  • Create video frame(s) of solid color red
  • Specify size of 1280x10

ffmpeg-filters 11.183 overlay (x; y; shorttest)

  • Relative to left-top corner, place at horizontal coordinate x, -w (negative number) pixels away from the left, positively increasing by +(w/10), where 10 is total seconds, across time *t (fractional seconds at instant), until it reaches the rightmost edge.
  • Relative to x-top corner, place at vertical coord y, H-h pixels away from the bottom.
  • Proceed into next frame as soon as possible and reevaluate expressions.

-c:a copy copies the audio stream, if it has one.

Cailean answered 20/5 at 9:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.