gpt4 book ai didi

video - FFMPEG:使用drawtext以及自动换行和填充创建视频

转载 作者:行者123 更新时间:2023-12-04 23:02:37 35 4
gpt4 key购买 nike

我正在使用 drawtext 过滤器从文本创建视频。输出视频我可以看到文本溢出而不是换行。

有什么办法可以存档自动换行并将内部填充设置为视频?

下面是我用来从文本生成视频的片段

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

输出看起来像这样
enter image description here

最佳答案

使用 subtitles filter反而。

enter image description here

ffmpeg -y -f lavfi -i color=c=white:s=640x480:d=5 -vf "subtitles=subs.srt" output.mp4

您可以手动或通过 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.

ASS 文件在结构上更复杂,但它们允许更多格式选项。否则,您可以使用 force_style字幕过滤器中的选项。在这个网站上搜索几个例子。

关于video - FFMPEG:使用drawtext以及自动换行和填充创建视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51906491/

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