ffmpeg如何在视频上添加彩色叠加层(ffmpeg how to put color overlay over video)

编程入门 行业动态 更新时间:2024-10-06 12:19:10
ffmpeg如何在视频上添加彩色叠加层(ffmpeg how to put color overlay over video)

我想在视频上放置一个颜色叠加(蓝色,红色或绿色或十六进制值),为它提供类似Instagram效果的滤镜。

我认为应该是这样的:

ffmpeg -i video.mp4 -i "red.png" -filter_complex "blend=all_mode='screen':all_opacity=0.7" output.mp4

或者也许是all_mode=overlay

但是我收到一个错误:

First input link top parameters (SAR 0:1) do not match the corresponding second input link bottom parameters (SAR 1:1).

我也试过lutrgb=r=1.5 ,但是没有给它一个红色(它取红色)。

我究竟做错了什么 ?

I want to put a color overlay (blue, red or green or hex value) over a video giving it a Instagram filter like effect.

I think it should be in the lines of:

ffmpeg -i video.mp4 -i "red.png" -filter_complex "blend=all_mode='screen':all_opacity=0.7" output.mp4

or maybe with all_mode=overlay

But I get an error:

First input link top parameters (SAR 0:1) do not match the corresponding second input link bottom parameters (SAR 1:1).

I also tried with lutrgb=r=1.5, but that didn't give it a red color (it takes the red away).

What am i doing wrong ?

最满意答案

两个输入必须共享相同的尺寸和SAR。 您可以使用setsar过滤器设置相同的SAR,也可以使用color完全避免使用图像文件:

ffmpeg -i video.mp4 -f lavfi -i "color=red:s=1280x720" -filter_complex "blend=shortest=1:all_mode=screen:all_opacity=0.7" output.mp4

其中s=1280x720是输入视频帧的大小。

颜色具有[0x|#]RRGGBB[AA]格式。


更新:

如果您仍然遇到输入视频SAR问题,请尝试使用setsar过滤器明确设置它:

ffmpeg -i video.mp4 -f lavfi -i "color=red:s=1280x720" \ -filter_complex "[0:v]setsar=sar=1/1[s];\ [s][1:v]blend=shortest=1:all_mode=screen:all_opacity=0.7[out]" \ -map [out] -map 0:a output.mp4

The two inputs must share the same dimensions and SAR. You can either use the setsar filter to set the same SAR or you can avoid using an image file completely by using color:

ffmpeg -i video.mp4 -f lavfi -i "color=red:s=1280x720" -filter_complex "blend=shortest=1:all_mode=overlay:all_opacity=0.7" output.mp4

Where s=1280x720 is the size of the input video frame.

The color has the [0x|#]RRGGBB[AA] format.


Update:

If you still have issues with the input video SAR try to explicitly set it using the setsar filter:

ffmpeg -i video.mp4 -f lavfi -i "color=red:s=1280x720" \ -filter_complex "[0:v]setsar=sar=1/1[s];\ [s][1:v]blend=shortest=1:all_mode=overlay:all_opacity=0.7[out]" \ -map [out] -map 0:a output.mp4

更多推荐

本文发布于:2023-07-04 09:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1022317.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:彩色   如何在   视频   ffmpeg   video

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!