gpt4 book ai didi

video - 如何简化ffmpeg的脚本?

转载 作者:行者123 更新时间:2023-12-04 23:14:45 25 4
gpt4 key购买 nike

我希望简化此脚本

我有这个给定的简单脚本;我想简化这个脚本,任何人都可以帮助我添加具有适当时间间隔的文本并淡入淡出效果。

ffmpeg -y -i video.mp4 -filter_complex \
"[0]split[base][text];[text] \
drawtext=fontfile=gvr.otf:text='Which of these is not an event listener adapter defined in the java.awt.event package?': fontcolor=white: fontsize=40: x=100:y=200, \
format=yuva444p,fade=t=in:st=1:d=1:alpha=1,fade=t=out:st=8:d=1:alpha=1[subtitles]; \
[base][subtitles]overlay" test_out.mp4

ffmpeg -y -i test_out.mp4 -filter_complex \
"[0]split[base][text];[text] \
drawtext=fontfile=gvr.otf:text='a) public void apple(String s, int i) {}': fontcolor=white: fontsize=40: x=100:y=(200) + 50 * 2, \
format=yuva444p,fade=t=in:st=3:d=1:alpha=1,fade=t=out:st=8:d=1:alpha=1[subtitles]; \
[base][subtitles]overlay" test_out1.mp4

ffmpeg -y -i test_out1.mp4 -filter_complex \
"[0]split[base][text];[text] \
drawtext=fontfile=gvr.otf:text='b) public int apple(int i, String s) {}': fontcolor=white: fontsize=40: x=100:y=(200) + 50 * 3, \
format=yuva444p,fade=t=in:st=4:d=1:alpha=1,fade=t=out:st=8:d=1:alpha=1[subtitles]; \
[base][subtitles]overlay" test_out2.mp4

ffmpeg -y -i test_out2.mp4 -filter_complex \
"[0]split[base][text];[text] \
drawtext=fontfile=gvr.otf:text='c) public void apple(int i, String mystring) {}': fontcolor=white: fontsize=40: x=100:y=(200) + 50 * 4, \
format=yuva444p,fade=t=in:st=5:d=1:alpha=1,fade=t=out:st=8:d=1:alpha=1[subtitles]; \
[base][subtitles]overlay" test_out3.mp4

ffmpeg -y -i test_out3.mp4 -filter_complex \
"[0]split[base][text];[text] \
drawtext=fontfile=gvr.otf:text='d) public void Apple(int i, String s) {}': fontcolor=white: fontsize=40: x=100:y=(200) + 50 * 5, \
format=yuva444p,fade=t=in:st=6:d=1:alpha=1,fade=t=out:st=8:d=1:alpha=1[subtitles]; \
[base][subtitles]overlay" test_out4.mp4

最佳答案

您可以在 drawtext 中使用 alpha 表达式

ffmpeg -y -i video.mp4 -vf "\
drawtext=fontfile=gvr.otf:text='Which of these is not an event listener adapter defined in the java.awt.event package?':fontcolor=white:fontsize=40:x=100:y=200:alpha='lte(t,2)*(t-1)+between(t,2,8)*1+gte(t,8)*(1-(t-8))', \
drawtext=fontfile=gvr.otf:text='a) public void apple(String s, int i) {}':fontcolor=white:fontsize=40:x=100:y=(200) + 50 * 2:alpha='lte(t,3)*(t-2)+between(t,3,8)*1+gte(t,8)*(1-(t-8))', \
drawtext=fontfile=gvr.otf:text='b) public int apple(int i, String s) {}':fontcolor=white:fontsize=40:x=100:y=(200) + 50 * 3:alpha='lte(t,4)*(t-3)+between(t,4,8)*1+gte(t,8)*(1-(t-8))', \
drawtext=fontfile=gvr.otf:text='c) public void apple(int i, String mystring) {}':fontcolor=white:fontsize=40:x=100:y=(200) + 50 * 4:alpha='lte(t,5)*(t-4)+between(t,5,8)*1+gte(t,8)*(1-(t-8))', \
drawtext=fontfile=gvr.otf:text='d) public void Apple(int i, String s) {}':fontcolor=white:fontsize=40:x=100:y=(200) + 50 * 5:alpha='lte(t,6)*(t-5)+between(t,6,8)*1+gte(t,8)*(1-(t-8))'" out.mp4

每个 alpha 表达式的形式为
alpha='lte(t,FADEIN-END-TIME)*(t-FADEIN-START-TIME)+between(t,OPAQUE-START-TIME,OPAQUE-END-TIME)*1+gte(t,FADEOUT-START-TIME)*(1-(t-FADEOUT-START-TIME))'

关于video - 如何简化ffmpeg的脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49511325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com