简体   繁体   English

使用 scale2ref 难题的水印 - 视频调整大小以适应水印而不是水印缩放以适合视频

[英]Watermarking with scale2ref conundrum - video resizes to watermark rather than watermark scaling to fit video

Hope you can hep me figure out where I am misleading myself.希望你能帮我弄清楚我在哪里误导了自己。 I am trying to watermark a bunch of videos with varying resolution sizes with a.png watermark file that is 1200x600.我正在尝试使用 1200x600 的 .png 水印文件为一堆具有不同分辨率大小的视频添加水印。 I have videos that are as large as 2480x1280 and as small as 360x141.我有大到 2480x1280 小到 360x141 的视频。

I had originally thought that ffmpeg could handle it, but I am having issues with the conversion, and I am pretty sure it is my misunderstanding of how to leverage scale2ref command properly.我原本以为 ffmpeg 可以处理它,但我在转换时遇到了问题,我很确定这是我对如何正确利用 scale2ref 命令的误解。 Now, from scale2ref documentation they say this:现在,从 scale2ref 文档中他们这样说:

Scale a subtitle stream (b) to match the main video (a) in size before overlaying在叠加之前缩放字幕 stream (b) 以匹配主视频 (a) 的大小

'scale2ref[b][a];[a][b]overlay' 'scale2ref[b][a];[a][b]覆盖'

I understand that stream[b] is my watermark file, and stream[a] is my video file.我知道 stream[b] 是我的水印文件,而 stream[a] 是我的视频文件。

My ffmpeg command is this:我的 ffmpeg 命令是这样的:

while read -r line || [[ -n "$line" ]]; do fn_out="w$line"; (/u2/vidmarktest/scripttesting/files_jeud8334j/dioffmpeg/ffmpeg -report -nostdin -i /u2/vidmarktest/scripttesting/files_jeud8334j/"$line" -i /u2/vidmarktest/mw1.1200x600.png -filter_complex "scale2ref[b][a];[b][a]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2" /u2/vidmarktest/scripttesting/files_jeud8334j/converted/"$fn_out" -c:v libx265); done < videos.txt 

To do some 'splainin, it is going to be part of a bash script that will be cron-ed so we can make sure we have all our latest submissions to the directory watermarked.为了做一些“splainin”,它将成为 bash 脚本的一部分,该脚本将被 cron-ed,因此我们可以确保我们将所有最新提交的目录都加水印。

The problem is this:问题是这样的:

All of my converted videos are scaled to fit 1200x600 now, rather than remaining in their original configuration with the watermark being the part that should be scaled to fit the video.我所有转换后的视频现在都缩放为适合 1200x600,而不是保留其原始配置,水印是应该缩放以适合视频的部分。

To note, that in this section: [b][a]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2, many will say I need to switch the [a] and [b] values.请注意,在本节中:[b][a]overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2,很多人会说我需要切换 [a] 和 [b] ] 值。 When you do that, the watermark is obscured by the video, not interlaced.当您这样做时,水印会被视频遮住,而不是隔行扫描。 Switching those two values puts the [b] value (the watermark) over the [a] value (the video).切换这两个值会将 [b] 值(水印)置于 [a] 值(视频)之上。

Any feedback will be highly appreciated, welcomed, and graded:)任何反馈都将受到高度赞赏、欢迎和评分:)

I am expecting to get the watermark to adjust to the video resolution, but am failing miserably.我希望让水印适应视频分辨率,但失败得很惨。 What do I not know about ffmpeg and scale2ref that is causing my problem?关于导致我的问题的 ffmpeg 和 scale2ref 我不知道什么?

In the command, your video is the first input, and the watermark the 2nd.在命令中,您的视频是第一个输入,水印是第二个。 In scale2ref, the inputs aren't explicitly set, so ffmpeg picks streams in input order, whereas you need the watermark to be the first input.在 scale2ref 中,未明确设置输入,因此 ffmpeg 按输入顺序选择流,而您需要将水印作为第一个输入。

Use [1:v][0:v]scale2ref[wm][v];[v][wm]overlay=...使用[1:v][0:v]scale2ref[wm][v];[v][wm]overlay=...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM