想要把带渐变色的字幕用ffmpeg烧入视频。
调研
1.使用 aegisub
+VSFilterMod
的方式很容易实现
参考:https://www.jianshu.com/p/1453265b4b5d
但是生成的.ass文件不能用ffmpeg渲染,原因是ffmpeg使用的字幕库是libass,不支持VSFilterMod扩展。详情:
https://github.com/libass/libass/issues/314
2.交叉编译VSFilterMod。结论:不支持linux
3.使用lua脚本
Aegisub支持lua脚本来执行一些自动化的工作。在github中已经有了实现的相关脚本,发现其本质是对Aegisub中支持的标签参数进行梯度化(Gradient)。
于是,对于字幕渐变色问题的可以归结到对两个颜色之间进行梯度化,通过像素点和字体大小来决定梯度化的粒度。
搞清楚Lua脚本的原理,完全可以自己实现由两个颜色之间的线性插值算法,并用\clip
标签对字幕部分显示,生成渐变字幕文件:
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(576,527,581,595)\pos(655,591.143)\fs65\be5\c&H00FF00&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(581,527,586,595)\pos(655,591.143)\fs65\be5\c&H08F701&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(586,527,591,595)\pos(655,591.143)\fs65\be5\c&H0FF002&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(591,527,596,595)\pos(655,591.143)\fs65\be5\c&H17E802&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(596,527,601,595)\pos(655,591.143)\fs65\be5\c&H1FE003&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(601,527,606,595)\pos(655,591.143)\fs65\be5\c&H26D804&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(606,527,611,595)\pos(655,591.143)\fs65\be5\c&H2ED105&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(611,527,616,595)\pos(655,591.143)\fs65\be5\c&H36C905&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(616,527,621,595)\pos(655,591.143)\fs65\be5\c&H3DC106&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(621,527,626,595)\pos(655,591.143)\fs65\be5\c&H45BA07&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(626,527,631,595)\pos(655,591.143)\fs65\be5\c&H4DB208&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(631,527,636,595)\pos(655,591.143)\fs65\be5\c&H54AA09&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(636,527,641,595)\pos(655,591.143)\fs65\be5\c&H5CA209&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(641,527,646,595)\pos(655,591.143)\fs65\be5\c&H649B0A&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(646,527,651,595)\pos(655,591.143)\fs65\be5\c&H6B930B&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(651,527,656,595)\pos(655,591.143)\fs65\be5\c&H738B0C&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(656,527,661,595)\pos(655,591.143)\fs65\be5\c&H7A840C&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(661,527,666,595)\pos(655,591.143)\fs65\be5\c&H827C0D&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(666,527,671,595)\pos(655,591.143)\fs65\be5\c&H8A740E&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(671,527,676,595)\pos(655,591.143)\fs65\be5\c&H916C0F&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(676,527,681,595)\pos(655,591.143)\fs65\be5\c&H996510&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(681,527,686,595)\pos(655,591.143)\fs65\be5\c&HA15D10&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(686,527,691,595)\pos(655,591.143)\fs65\be5\c&HA85511&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(691,527,696,595)\pos(655,591.143)\fs65\be5\c&HB04D12&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(696,527,701,595)\pos(655,591.143)\fs65\be5\c&HB84613&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(701,527,706,595)\pos(655,591.143)\fs65\be5\c&HBF3E14&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(706,527,711,595)\pos(655,591.143)\fs65\be5\c&HC73614&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(711,527,716,595)\pos(655,591.143)\fs65\be5\c&HCF2F15&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(716,527,721,595)\pos(655,591.143)\fs65\be5\c&HD62716&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(721,527,726,595)\pos(655,591.143)\fs65\be5\c&HDE1F17&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(726,527,731,595)\pos(655,591.143)\fs65\be5\c&HE61717&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(731,527,736,595)\pos(655,591.143)\fs65\be5\c&HED1018&}非fsdf
Dialogue: 0,0:00:00.00,0:00:05.00,Default,,0,0,0,,{\clip(736,527,741,595)\pos(655,591.143)\fs65\be5\c&HF50819&}非fsdf
效果如下:
jianshu.pngffmpeg支持的libass库可以支持这些标签,因此可以烧视频实现渐变字幕的效果。
网友评论