大家论坛

 找回密码
 注册
查看: 2638|回复: 1

[讨论] FFmpeg video overlay

[复制链接]

1295

主题

1308

帖子

1310

金币

大家网研究生四年级

Rank: 25Rank: 25Rank: 25Rank: 25Rank: 25

积分
5457
发表于 2018-8-5 15:46 | 显示全部楼层 |阅读模式
I am trying to overlay an input video with many images where each image should be shown for a short time. I achieved this using complex filter (the command below). The problem is that I have many, many images (>1000) :-)
ffmpeg -y -i in.mp4 -i logo1.png -i logo2.png -i logo3.png -filter_complex "[0:v][1:v] overlay=10:10:enable='between(n,2,4)'    [tmp]; [tmp][2:v] overlay=30:30:enable='between(n,6,8)'    [tmp]; [tmp][3:v] overlay=50:50:enable='between(n,10,12)'; " out.mp4
Does FFmpeg allows a user to pass this data over a text-file ? The images are generated in memory, so pipes are also fine (in fact preferred).
(if that is not possible can I pass raw generated video in Bgra format ?; but I would not prefer this because the blend operation is more expensive + more IO: has to be as fast as possible)

Edit: If I use the following configuration, only the last sent image is overlayed.
-i ski.mp4 -f image2pipe -vcodec png -i --filter_complex "[0:v][1:v] overlay=10:10:enable='between(n,2,3)' [tmp];                  [tmp][1:v] overlay=30:30:enable='between(n,6,7)'"-f mp4", "out.mp4"
FFmpeg outputs (it seems that it skips images if they have different sizes):
Input stream #1:0 frame changed from size:1417x665 fmt:rgba to size:1800x700 fmt:rgba Input stream #1:0 frame changed from size:1800x700 fmt:rgba to size:550x371 fmt:rgba Input stream #1:0 frame changed from size:550x371 fmt:rgba to size:256x256 fmt:rgba
How can I instruct FFmpeg that for the first filter uses 1st image, for the second 2nd image in pipe, etc. (the images have different sizes) ?

本人工科计算机专业程序媛一枚,感谢大家论坛并奉献本人收集的计算机资料,若本贴不能下载请回复,其他事由请点击这里
回复

使用道具 举报

1295

主题

1308

帖子

1310

金币

大家网研究生四年级

Rank: 25Rank: 25Rank: 25Rank: 25Rank: 25

积分
5457
 楼主| 发表于 2018-8-5 15:47 | 显示全部楼层
an expression, then this can be made as a manageable command.

You can input the images via pipe using the -f image2pipe -vcodec png as an input option.

Also, FFmpeg can reference a filterchain from a script

-filter_complex_script filename (global)

This option is similar to -filter_complex, the only difference is that its argument is the name of the file from which a complex filtergraph description is to be read.
本人工科计算机专业程序媛一枚,感谢大家论坛并奉献本人收集的计算机资料,若本贴不能下载请回复,其他事由请点击这里
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则



诚聘英才|移动端|Archiver|版权声明|大家论坛 ( 京ICP备06071611号,京公网安备11010802018363号 )

GMT+8, 2020-1-18 12:24 , Processed in 0.079905 second(s), 8 queries , Redis On.

Powered by Discuz!

© Comsenz Inc.

快速回复 返回顶部 返回列表