ChinaFFmpeg

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 15051|回复: 1

ffmpeg同时叠加字幕和水印

[复制链接]
发表于 2017-2-8 19:26:56 | 显示全部楼层 |阅读模式
1.环境:ubuntu16.04 64位

2.编解码使用nvidia的硬件加速接口

3.使用方式ffmpeg api调用;

4.video_filter_spec定义如下:
char *video_filter_spec = "drawtext=fontfile=FreeSerif.ttf:\
fontsize=36: \
fontcolor=yellow@1.0: \
x='if(gte(t,5), (main_w-mod(t*30,main_w+text_w)), NAN)':\
y=500:\
text='Hello, this is drawtext function,any more questsion can concat su.gao(sugao_cn@163.com)!' [text];  \
movie=/root/mscore/extern/source/logo/test.png [wm]; \
[text] [wm] overlay=0:0 [out]";


使用的filters如下
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1362]        nb_filters:5
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1369]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1370]        filters:in(buffer)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1372]        filters outputs:default(0)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1373]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1369]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1370]        filtersut(buffersink)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1371]        filters inputs:default(0)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1373]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1369]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1370]        filtersarsed_drawtext_0(drawtext)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1371]        filters inputs:default(0)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1372]        filters outputs:default(0)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1373]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1369]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1370]        filtersarsed_movie_1(movie)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1373]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1369]        ----------------------
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1370]        filtersarsed_overlay_2(overlay)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1371]        filters inputs:main(0)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1372]        filters outputs:default(0)
2017-02-08 19:11:26[msffmpeg_opt_set]        [driver/ffmpeg_opt_set.c msffmpeg_api_initvideofilters 1373]        ----------------------


效果图:


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

发表于 2017-2-9 19:16:11 | 显示全部楼层
多谢支持,给加个精华
回复 支持 反对

使用道具 举报

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

本版积分规则

手机版|Archiver|ChinaFFmpeg

GMT+8, 2024-12-27 01:50 , Processed in 0.071883 second(s), 16 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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