Adding a background to an in-video visual progress bar with FFMPEG?
Asked Answered
B

2

0

Using the answer to Showing in-video visual progress bar with FFMPEG
https://static.mcmap.net/file/mcmap/ZG-AbGLDKwfpKnMxcF_AZVLQamyA/ASjyL.gif

I'm trying to give the progress bar itself a background, so for e.g. the bar will be white and the red progress bar over time will cover it.

My first decision was to apply a drawbox filter, so for my purposes the video is 1280 pixels wide and the duration is 6.027 seconds. I've tried

ffmpeg -i uuid_nordvpn.mp4 -vf "color=c=red:s=1280x30[bar];[0][bar]overlay=-w+(w/6.072733)*t:H-h:shortest=1, drawbox=x=0:y=720-30:width=1280:height=30:thickness=fill:color=white" out.mp4

But I got just the white drawbox filter that was drawn on top of the color filter. enter image description here

The obvious solution was to swap the color and drawbox filter, but that returns an error Too many inputs specified for the "color" filter, which I guess means you can only use the color filter at the beginning.

I've also tried applying 2 color filters, the other color filter instead of filling up was going down, but you can't apply 2 color filters, again giving the reason Too many inputs specified for the "color" filter.

I'm completely lost at this point, how would I give a background to this filter?

Beaner answered 24/2, 2022 at 1:6 Comment(0)
C
2

You can use multiple color filters. But color filter is a source filter, so it cannot appear in the middle of your filter chain (which is what the error message is saying). It must be the first filter of a chain. This should work for you:

edit: your approach to slide with overlay is faster than my original scale approaches. I've added all 4 implementations with observed speed:

1. 2xcolor+2xoverlay: x14.1

ffmpeg -i uuid_nordvpn.mp4 \
  -vf 'color=c=white:s=1280x30[L0]; \
       color=c=red:s=1280x30[L1]; \
       [L0][L1]overlay=(t/6.072733-1)*w:0:eval=frame[L2]; \
       [in][L2]overlay=0:690:shortest=1[out]' \
  out.mp4

2. drawbox + color + overlay: 13.4x

ffmpeg -i uuid_nordvpn.mp4 \
  -vf '[in]drawbox=0:690:1280:30:white:fill[L0]; \
       color=c=red:s=1280x30[L1]; \
       [L0][L1]overlay=(t/6.072733-1)*w:690:eval=frame:shortest=1[out]' \
  out.mp4

3. 2xcolor+scale+2xoverlay: 5.09x

ffmpeg -i uuid_nordvpn.mp4 \
  -vf 'color=c=white:s=1280x30[L0]; \
       color=c=red:s=1280x30,scale=max(t/6.072733*in_w\,1):in_h:eval=frame[L1]; \
       [L0][L1]overlay=0:0[L2]; \
       [in][L2]overlay=0:690:shortest=1[out]' \
  out.mp4

4. drawbox + color + scale + overlay: 5.03x

ffmpeg -i uuid_nordvpn.mp4 \
  -vf '[in]drawbox=0:690:1280:30:white:fill[L0]; \
       color=c=red:s=1280x30,scale=max(t/6.072733*in_w\,1):in_h:eval=frame[L1]; \
       [L0][L1]overlay=0:690:shortest=1[out]' \
  out.mp4
Cancroid answered 24/2, 2022 at 2:4 Comment(0)
F
0

@kesh's answer is great. Here's another alternative if you don't want to overwrite any video data (pad an extra 30px to the bottom instead):

ffmpeg -i uuid_nordvpn.mp4 \
  -vf '[in]pad=in_w:in_h+30:0:0:white[pad]; \
       color=c=red:s=1280x30[bar]; \
       [pad][bar]overlay=-w+(w/6.072733)*t:H-h:shortest=1' \
out.mp4
Fictile answered 22/9, 2023 at 4:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.