Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Video 如何简化ffmpeg的脚本?_Video_Ffmpeg_Simplify - Fatal编程技术网

Video 如何简化ffmpeg的脚本?

Video 如何简化ffmpeg的脚本?,video,ffmpeg,simplify,Video,Ffmpeg,Simplify,我想简化这个脚本 我有这个简单的剧本;我想简化这个脚本,任何人都可以帮助我添加具有适当时间间隔和淡入淡出效果的文本 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?':

我想简化这个脚本

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

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))'

这个给定的youtube视频是由上述脚本创建的