我正在努力使用绘图文本过滤器从文本创建视频。输出视频我可以看到文本溢出而不是换行。
有什么方法可以存档自动换行并将内部填充设置为视频?
下面是我用来从文本生成视频的片段
ffmpeg.exe -f lavfi -i color=c=white:s=640x480:d=5.396 -vf "[in] drawtext=fontfile=font.ttf:fontsize=20:fontcolor=black:x=0+0*print(tw):y=0+0*print(th):text='this is new whiteboard te':enable='between(t,6.634,6.818)',drawtext=fontfile=font.ttf:fontsize=20:fontcolor=black:x=0+0*print(tw):y=0+0*print(th):text='this is new whiteboard testing':enable='between(t,0.0,2.032)',drawtext=fontfile=font.ttf:fontsize=20:fontcolor=black:x=0+0*print(tw):y=0+0*print(th):text='this is new whiteboard testing no padding and the text is overflowing from the video frame check this need to acheve word wrapping':enable='between(t,2.032,5.396)'"[out] -c:v libx264 -t 30 -crf 30 ../output.mp4
Run Code Online (Sandbox Code Playgroud)
请改用字幕过滤器。
ffmpeg -y -f lavfi -i color=c=white:s=640x480:d=5 -vf "subtitles=subs.srt" output.mp4
Run Code Online (Sandbox Code Playgroud)
您可以手动或通过 Aegisub 生成 ASS 或 SRT 字幕。
SRT 示例:
1
00:00:00,000 --> 00:00:05,000
This is new whiteboard testing no padding and the text is overflowing from the video frame check this need to acheve word wrapping.
Run Code Online (Sandbox Code Playgroud)
ASS 文件在结构上更复杂,但它们允许更多格式选项。否则,您可以使用force_style字幕过滤器中的选项。在此站点中搜索几个示例。