如何在ffmpeg命令中扩展和添加正确的徽标? [英] How to scale and add correct a logo in ffmpeg command?
问题描述
我正在尝试应用水印,还可以通过ffmpeg命令将其缩放到当前的视频大小:
I am trying to apply a watermark and also to scale it to the current video size via ffmpeg command:
这里是我没有水印的工作原理, p>
Here is my inital comand that works without watermark
ffmpeg -v 0 -vcodec h264_qsv -i 'udp://@some.ip:1234?fifo_size=1000000&overrun_nonfatal=1&buffer_size=1000000' -vf scale=iw:ih -profile baseline -acodec aac -ac 1 -ar 44100 -ab 64k -deinterlace -vcodec h264_qsv -bufsize 4000k -maxrate 3500k -preset veryfast -vb 2000k -f flv rtmp://127.0.0.1/app/720
现在我试图将图片添加为水印。与 -vf scale = -1:ih * .5
一起使用时出现冲突,以消除我使用的问题 -s 1280x720
指定视频流的分辨率,但是它的工作不正确。
Now I tried to add the picture as a watermark. There was a conflict while using with -vf scale=-1:ih*.5
, in order to eliminate the problem I used -s 1280x720
to specify the resolution for the video stream, it worked but not properly.
ffmpeg -v 0 -vcodec h264_qsv -i 'udp://@some.ip:1234?fifo_size=1000000&overrun_nonfatal=1&buffer_size=1000000' -i logo.png -filter_complex "overlay=10:10" -s 1280x720 -profile baseline -acodec aac -ac 1 -ar 44100 -ab 64k -deinterlace -vcodec h264_qsv -bufsize 4000k -maxrate 3500k -preset veryfast -vb 2000k -f flv rtmp://some.ip/app/720
问题:
ffmpeg命令的两个尺寸的视频和标志(水印),所以他们不会相互冲突,他们会像 -vf scale = -1:ih * .5
How can I specify in the ffmpeg command the both sizes of video and logo(watermark) so they don't conflict with each other and they auto adjust like -vf scale=-1:ih*.5
dose.
谢谢!
推荐答案
scale2ref过滤器一个到视频/图像流参考另一视频或图像流的尺寸
The scale2ref filter allows one to a video/image stream with reference to the dimensions of another video or image stream
例如。
ffmpeg -v 0 -vcodec h264_qsv -i 'udp://@some.ip:1234?fifo_size=1000000&overrun_nonfatal=1&buffer_size=1000000' \
-loop 1 -i logo.png \
-filter_complex "[1:v][0:v]scale2ref=iw/8:-1[logo][0v];[0v][logo]overlay=10:10[v]" \
-map "[v]" -map 0:a \
-profile baseline -acodec aac -ac 1 -ar 44100 -ab 64k \
-deinterlace -vcodec h264_qsv -bufsize 4000k -maxrate 3500k \
-preset veryfast -vb 2000k \
-f flv rtmp://some.ip/app/720
这里 1:v
- 标志图像 - 被缩放到宽度为$ code> [0:v] 的H.264流。
Here 1:v
- the logo image - is being scaled to 1/8th the width of [0:v]
, the H.264 stream.
对于评论中给出的命令:
For the command given in the comments:
ffmpeg -v 0 -vcodec h264_qsv -i 'input' \
-loop 1 -i logo.png \
-filter_complex "[0:v]scale=iw:ih[v0]; \
[1:v][v0]scale2ref=iw/8:-1[logo][0v];[0v][logo]overlay=10:10[v]" \
-map "[v]" -map 0:a \
-profile baseline -acodec aac -ac 1 -ar 44100 -ab 64k \
-deinterlace -vcodec h264_qsv -bufsize 4000k -maxrate 3500k \
-preset veryfast -vb 2000k \
-f flv out1 \
-filter_complex "[0:v]scale=-1:ih/2[v0]; \
[1:v][v0]scale2ref=iw/8:-1[logo][0v];[0v][logo]overlay=10:10[v2]" \
-map "[v2]" -map 0:a \
-profile baseline -acodec aac -ac 1 -ar 44100 -ab 64k \
-deinterlace -vcodec h264_qsv -bufsize 4000k -maxrate 2000k \
-preset veryfast -vb 1000k \
-f flv out2 \
-filter_complex "[0:v]scale=-1:ih/4[v0]; \
[1:v][v0]scale2ref=iw/8:-1[logo][0v];[0v][logo]overlay=10:10[v3]" \
-map "[v3]" -map 0:a \
-profile baseline -acodec aac -ac 1 -ar 44100 -ab 64k \
-deinterlace -vcodec h264_qsv -bufsize 4000k -maxrate 1000k \
-preset veryfast -vb 512k \
-f flv out3 \
这篇关于如何在ffmpeg命令中扩展和添加正确的徽标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!