关闭

watermarking-videos-from-the-command-line-using-ffmpeg-filters

462人阅读 评论(0) 收藏 举报

http://ksloan.net/watermarking-videos-from-the-command-line-using-ffmpeg-filters/


Kevin Sloan

Software Developer

Watermarking Videos from the Command Line with FFMPEG Filters

FFMPEG filters provide a powerful way to programmatically enhance or alter videos, and it’s fairly simple to add a watermark to a video using the overlay filter. The easiest way to install ffmpeg is to download a pre-built binary for your specific platform. Then you don’t have to worry about including and installing all the right dependencies and codecs you will be using.

Here’s a short video I took while mountain biking that we’ll be working with.


Video Player

Once you have ffmpeg installed, adding a watermark is as easy as passing your existing source through an overlay filter like so:

ffmpeg -i birds.mp4 -i watermark.png -filter_complex "overlay=10:10" birds1.mp4

Basically, we’re passing in the original video, and an overlay image as inputs, then passing it through the filter, and saving the output as birds1.mp4.

We specify a specific position of the overlay in pixels – 10:10 puts the video 10 pixels from the top and 10 pixels from the right. (x:y coordinates)

Here is our result:


Video Player
00:00
00:05

In some cases you might not know the exact dimensions of the videos you’ll be watermarking. Fortunately, there are variables you can use to better position your watermark depending on the size of the video. These variables include:

  • main_h – the video’s height
  • main_w – the video’s width
  • overlay_h – the overlay’s height
  • overlay_w – the overlay’s width

Using these variable we can position the watermark right in the center of the video like so:

ffmpeg -i birds.mp4 -i watermark.png \
-filter_complex "overlay=x=(main_w-overlay_w)/2:y=(main_h-overlay_h)/2" birds2.mp4


Video Player
00:00
00:05

If we wanted to add branding or a watermark to the clip but not cover the existing video, we can use the pad filter to add some padding to our clip, and then position our watermark over the padding like so:

ffmpeg -i birds.mp4 -i watermark2.png \
-filter_complex "pad=height=ih+40:color=#71cbf4,overlay=(main_w-overlay_w)/2:main_h-overlay_h" \
birds3.mp4


Video Player
00:00
00:05

Once you start getting the hang of this, you can even animate your overlays!

ffmpeg -i birds.mp4 -i watermark.png \
-filter_complex "overlay='if(gte(t,1), -w+(t-1)*200, NAN)':(main_h-overlay_h)/2" birds4.mp4


Video Player
00:00
00:05

That’s it! Simple. Please leave comments below if you have any questions!


0
0
查看评论
发表评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场

Github入门级使用攻略(续)

转载请注明出处 http://blog.csdn.net/pony_maggie/article/details/6568192 作者:小马 九 如何整合windows cmd命令行与gi...
  • pony_maggie
  • pony_maggie
  • 2014-12-27 23:18
  • 12450

使用runInstaller 的executePrereqs选项来验证os是否符合oracle db software的安装要求

使用runInstaller来验证os是否符合oracle db software的安装要求
  • msdnchina
  • msdnchina
  • 2015-02-19 00:23
  • 3276

sqoop配置以及使用过程小结

使用sqoop用来将关系型数据库里的内容与HDFS上的内容互转。本文用sqoop测试2个内容: (1)将pg上数据移动到hdfs上; (2)将hdfs上数据移动到pg上; hadoop版本:2.7...
  • yeruby
  • yeruby
  • 2015-10-20 10:51
  • 4964

From Bash to Z Shell: Conquering the Command Line

  • 2015-08-17 15:46
  • 14.44MB
  • 下载

imagemagick_tricks_web_image_effects_from_the_command_line_and_php

  • 2011-08-25 10:29
  • 6.87MB
  • 下载

Using the 'nasl' Nessus Command Line Tool

http://blog.tenablesecurity.com/2007/06/using-the-nasl-.html http://www.virtualblueness.net/nasl.ht...
  • cnbird2008
  • cnbird2008
  • 2012-02-04 15:50
  • 1559

Docker - How to Connect to a MySQL Running Container Using MySQL Command Line Client

We used the official mysql image from Docker Hub (https://hub.docker.com/_/mysql/), and created a ru...
  • cs08211317dn
  • cs08211317dn
  • 2016-02-28 21:02
  • 823

[SDK学习]Managing Projects from the Command Line

Managing Projects from the Command Line In this document Creating an Android...
  • FrancisLeeTang
  • FrancisLeeTang
  • 2011-07-20 17:02
  • 283

ios 命令行编译 Build an iPhone app from the command line

http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art024 Build an iPhone app from the...
  • ssyyjj88
  • ssyyjj88
  • 2016-05-27 19:21
  • 760

MySQL5.6 Using a password on the command line interface can be insecure解决方法;

1.最近把MySQL从5.5升到5.6以后,mysqldump居然不好用了,提示:  代码如下 复制代码 [root@qttc ~]# /usr/lo...
  • wk1063645973
  • wk1063645973
  • 2015-11-01 21:40
  • 27453
    个人资料
    • 访问:240285次
    • 积分:2473
    • 等级:
    • 排名:第17255名
    • 原创:16篇
    • 转载:123篇
    • 译文:0篇
    • 评论:66条
    最新评论