FFmpeg 将覆盖从一个像素坐标移动到另一个像素坐标 [英] FFmpeg move overlay from one pixel coordinate to another

查看:17
本文介绍了FFmpeg 将覆盖从一个像素坐标移动到另一个像素坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 FFmpeg 中编写一个命令,该命令将首先将一个视频流叠加在另一个视频流之上.然后我希望叠加的视频在已知时间从一个像素坐标移动,并在稍后的时间在另一个像素坐标处结束.

I'm trying to write a command within FFmpeg that will first overlay one video stream on top of another one. Then I want the overlayed video to move from one pixel coordinate at a known time, and end at another pixel coordinate at a later time.

我对 -filter_complex 的基本知识感到满意,但我无法弄清楚如何应用任何算术表达式 - 就像这里引用的那个:https://www.ffmpeg.org/ffmpeg-utils.html#Expression-Evaluation

I'm comfortable with the basics of the -filter_complex, but I cannot figure out how to apply any arithmetic expressions - like the one's referenced here: https://www.ffmpeg.org/ffmpeg-utils.html#Expression-Evaluation

这是我想要完成的一个例子.

Here's an example of something I'd like to accomplish.

ffmpeg -i [INPUT1] -i [INPUT2] -filter_complex "[0:v][1:v]overlay=shortest=1:x=720:y=0:enable='between(t,10,20)'[overlay];...

在这个例子中,从第 10 秒到第 20 秒,叠加层在像素坐标 720x0 处是静止的.

In this example the overlay is stationary at pixel coordinate 720x0 from the 10th second to the 20th second.

但是,我想让它以线性方式移动到一个新位置并在不同的像素坐标处结束.

However, Id like to have it move to a new location in a linear fashion and end at a different pixel coordinate.

例如,在 10 秒叠加期间,我希望它从 720x0 开始,然后以 1000x100 结束.

For example, during that 10 second overlay, I'd like to have it start at 720x0, but then end at 1000x100.

这可能吗?

推荐答案

这是您要找的吗?

这个蹩脚的例子有 6 秒的持续时间.红框2秒后出现,3秒后结束.

This crappy example has a duration of 6 seconds. The red box appears after 2 seconds and ends 3 seconds later.

示例:

ffmpeg -i bg.mp4 -i fg.mkv -filter_complex 
"[0:v][1:v]overlay=enable='between=(t,10,20)':x=720+t*28:y=t*10[out]" 
-map "[out]" output.mkv

  • 在 10 秒内将 x 从位置 720 移动到 1000.这等于 28 像素/秒.

    • Move x from position 720 to 1000 in 10 seconds. That equals 28 pixels/second.

      y 很简单.

      t 是以秒为单位的时间戳.

      t is the timestamp in seconds.

      重叠的视频(在本例中为 fg.mkv)在出现时已经过了 10 秒.

      The overlaid video (fg.mkv in this example) will already be 10 seconds into its duration when it appears.

      这篇关于FFmpeg 将覆盖从一个像素坐标移动到另一个像素坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆