Create a black box over top of the video for a set duration at a set time.
Hello, What I'd like to achieve is sort of like censoring, but with a black box. I can find plenty of examples of how to add a black box to a video, but the problem is it is always either the whole video, or only at the beginning/end, that the examples add black boxes to. I cannot seem to figure out how to set the start and end timestamp. Thanks, David
On 23 Dec 2022, at 22:55, David Niklas <deference@null.net> wrote:
Hello, What I'd like to achieve is sort of like censoring, but with a black box.
I can find plenty of examples of how to add a black box to a video, but the problem is it is always either the whole video, or only at the beginning/end, that the examples add black boxes
Try filter_complex "[0:0]youfilter=enable='between(t,1.0,2.0)’” Hth Bouke
to. I cannot seem to figure out how to set the start and end timestamp.
Thanks, David _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
On Sat, 24 Dec 2022 10:48:14 +0100 Bouke / Videotoolshed <bouke@videotoolshed.com> wrote:
On 23 Dec 2022, at 22:55, David Niklas <deference@null.net> wrote:
Hello, What I'd like to achieve is sort of like censoring, but with a black box.
I can find plenty of examples of how to add a black box to a video, but the problem is it is always either the whole video, or only at the beginning/end, that the examples add black boxes
Try filter_complex "[0:0]youfilter=enable='between(t,1.0,2.0)’”
<snip> Sorry for taking so long to reply. It is not working. Terminal output below. % ffmpeg -i Ducksinarow.mp4 -filter_complex "[0:0]drawbox=color=black:t=fill=enable='between(t,1.0,2.0)'" -c:a copy -c:v libvpx ducks.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Ducksinarow.mp4': Metadata: major_brand : mp42 minor_version : 512 compatible_brands: mp42iso2avc1mp41 creation_time : 2022-12-20T06:17:11.000000Z Duration: 00:00:12.54, start: 0.000000, bitrate: 2864 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt709/bt709), 1920x1080 [SAR 1:1 DAR 16:9], 2759 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc (default) Metadata: creation_time : 2022-12-20T06:17:11.000000Z handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 129 kb/s (default) Metadata: creation_time : 2022-12-20T06:17:11.000000Z handler_name : Stereo File 'ducks.mp4' already exists. Overwrite? [y/N] y Stream mapping: Stream #0:0 (h264) -> drawbox drawbox -> Stream #0:0 (libvpx) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help [Parsed_drawbox_0 @ 0x55fd8cb28640] [Eval @ 0x7fff13ad4a50] Invalid chars '=enable=between(t,1.0,2.0)' at the end of expression 'fill=enable=between(t,1.0,2.0)' Last message repeated 5 times [Parsed_drawbox_0 @ 0x55fd8cb28640] Error when evaluating the expression 'fill=enable=between(t,1.0,2.0)'. [Parsed_drawbox_0 @ 0x55fd8cb28640] Failed to configure input pad on Parsed_drawbox_0 Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 # // Now without single quotes, just in case. % ffmpeg -i Ducksinarow.mp4 -filter_complex "[0:0]drawbox=color=black:t=fill=en able=between(t,1.0,2.0)" -c:a copy -c:v libvpx ducks.mp4 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'Ducksinarow.mp4': Metadata: major_brand : mp42 minor_version : 512 compatible_brands: mp42iso2avc1mp41 creation_time : 2022-12-20T06:17:11.000000Z Duration: 00:00:12.54, start: 0.000000, bitrate: 2864 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt470bg/bt709/bt709), 1920x1080 [SAR 1:1 DAR 16:9], 2759 kb/s, 25 fps, 25 tbr, 90k tbn, 180k tbc (default) Metadata: creation_time : 2022-12-20T06:17:11.000000Z handler_name : VideoHandler Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, stereo, fltp, 129 kb/s (default) Metadata: creation_time : 2022-12-20T06:17:11.000000Z handler_name : Stereo [AVFilterGraph @ 0x561ad3fff6c0] No such filter: '1.0' Error initializing complex filters. Invalid argument
On 2022-12-31 08:15 am, David Niklas wrote:
Sorry for taking so long to reply. It is not working. Terminal output below.
% ffmpeg -i Ducksinarow.mp4 -filter_complex "[0:0]drawbox=color=black:t=fill=enable='between(t,1.0,2.0)'" -c:a copy -c:v libvpx ducks.mp4
There should be a colon after fill, not = drawbox=color=black:t=fill:enable='between(t,1.0,2.0)' Regards, Gyan
On 31 Dec 2022, at 04:53, Gyan Doshi <ffmpeg@gyani.pro> wrote:
On 2022-12-31 08:15 am, David Niklas wrote:
Sorry for taking so long to reply. It is not working. Terminal output below.
% ffmpeg -i Ducksinarow.mp4 -filter_complex "[0:0]drawbox=color=black:t=fill=enable='between(t,1.0,2.0)'" -c:a copy -c:v libvpx ducks.mp4
There should be a colon after fill, not =
drawbox=color=black:t=fill:enable='between(t,1.0,2.0)'
And for your next question that might come up (since you want to do multiple filters, I do too and just got bitten): There is a limitation on Windows that won’t accept long arguments. In that case, save the filter_complex string to a file, then, instead of filter_complex you can use filter_complex_script with the filename as argument. Bouke
Am 31.12.2022 um 10:31 schrieb Bouke / Videotoolshed:
On 31 Dec 2022, at 04:53, Gyan Doshi <ffmpeg@gyani.pro> wrote:
On 2022-12-31 08:15 am, David Niklas wrote:
Sorry for taking so long to reply. It is not working. Terminal output below.
% ffmpeg -i Ducksinarow.mp4 -filter_complex "[0:0]drawbox=color=black:t=fill=enable='between(t,1.0,2.0)'" -c:a copy -c:v libvpx ducks.mp4 There should be a colon after fill, not =
drawbox=color=black:t=fill:enable='between(t,1.0,2.0)' And for your next question that might come up (since you want to do multiple filters, I do too and just got bitten): There is a limitation on Windows that won’t accept long arguments.
Do you have an example? I have used command lines _much_ longer than the above example, and never found a limitation. Michael
On 31 Dec 2022, at 10:41, Michael Koch <astroelectronic@t-online.de> wrote:
Am 31.12.2022 um 10:31 schrieb Bouke / Videotoolshed:
On 31 Dec 2022, at 04:53, Gyan Doshi <ffmpeg@gyani.pro> wrote:
On 2022-12-31 08:15 am, David Niklas wrote:
Sorry for taking so long to reply. It is not working. Terminal output below.
% ffmpeg -i Ducksinarow.mp4 -filter_complex "[0:0]drawbox=color=black:t=fill=enable='between(t,1.0,2.0)'" -c:a copy -c:v libvpx ducks.mp4 There should be a colon after fill, not =
drawbox=color=black:t=fill:enable='between(t,1.0,2.0)' And for your next question that might come up (since you want to do multiple filters, I do too and just got bitten): There is a limitation on Windows that won’t accept long arguments.
Do you have an example? I have used command lines _much_ longer than the above example, and never found a limitation.
Michael
The limitation is 8091 chars, and afaik only exists on Windows. (Mac is fine, I don’t know about Linux, but I suspect it will be no issue there too.) My latest issue had a line of more than 64000 chars, example from filter_complex (that caused the huge length) below. Bouke map 0:0 -filter_complex [0:0]drawtext=enable='between(t,0.030208333333333334,75.18016666666666)': timecode='00\:49\:29\:11':fontfile='/Volumes/Data/PycharmProjects/LTC_convert/src/main/resources/base/courbd.ttf':r=25:x=(w-text_w)/2:y=h-th: y=h-(2*lh):fontsize=54.0:fontcolor=white:borderw=2.7:bordercolor=#101010@0.8,drawtext=enable='between(t,75.19016666666667,75.78016666666666)':text='-- NO LTC !':fontfile='/Volumes/Data/PycharmProjects/LTC_convert/src/main/resources/base/courbd.ttf':x=(w-text_w)/2:y=h-th: y=h-(2*lh):fontsize=54.0:fontcolor=white:borderw=2.7:bordercolor=#101010@0.8,drawtext=enable='between(t,75.79016666666666,299.980125)':timecode='00\:47\:41\:21':fontfile='/Volumes/Data/PycharmProjects/LTC_convert/src/main/resources/base/courbd.ttf':r=25:x=(w-text_w)/2:y=h-th: y=h-(2*lh):fontsize=54.0:fontcolor=white:borderw=2.7:bordercolor=#101010@0.8,drawtext=enable='between(t,300.0300416666667,822.9397708333333)':timecode='00\:47\:41\:21':fontfile='/Volumes/Data/PycharmProjects/LTC_convert/src/main/resources/base/courbd.ttf':r=25:x=(w-text_w)/2:y=h-th: y=h-(2*lh):fontsize=54.0:fontcolor=white:borderw=2.7:bordercolor=#101010@0.8,drawtext=enable='between(t,822.9497708333333,1138.6619166666667)':text='-- NO LTC !':fontfile='/Volumes/Data/PycharmProjects/LTC_convert/src/main/resources/base/courbd.ttf':x=(w-text_w)/2:y=h-th: y=h-(2*lh):fontsize=54.0:fontcolor=white:borderw=2.7:bordercolor=#101010@0.8, and so on….
On Sat, 31 Dec 2022 09:23:30 +0530 Gyan Doshi <ffmpeg@gyani.pro> wrote:
On 2022-12-31 08:15 am, David Niklas wrote:
Sorry for taking so long to reply. It is not working. Terminal output below.
% ffmpeg -i Ducksinarow.mp4 -filter_complex "[0:0]drawbox=color=black:t=fill=enable='between(t,1.0,2.0)'" -c:a copy -c:v libvpx ducks.mp4
There should be a colon after fill, not =
drawbox=color=black:t=fill:enable='between(t,1.0,2.0)'
Thanks! That works like a charm! David
participants (5)
-
Bouke / edit 'B -
Bouke / Videotoolshed -
David Niklas -
Gyan Doshi -
Michael Koch