FFMPEG:使用drawtext以及自动换行和填充来创建视频 [英] FFMPEG: Creating video using drawtext along with word wrap and padding
问题描述
我正在使用drawtext过滤器根据文本创建视频.输出视频,我可以看到文本溢出而不是换行.
I'm working to create a video from text with drawtext filter. Output video i can see the text is overflowing instead of coming in new line.
我可以通过任何方式存档自动换行,也可以将内部填充设置为视频吗?
Is there any way i can archive word wrapping and also set the internal padding to video?
下面是我用来从文本生成视频的代码段
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
输出看起来像这样
推荐答案
使用字幕过滤器.
ffmpeg -y -f lavfi -i color=c=white:s=640x480:d=5 -vf "subtitles=subs.srt" output.mp4
您可以手动或通过Aegisub生成ASS或SRT字幕.
You can generate ASS or SRT subtitles manually or via Aegisub.
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
选项.在该网站上搜索几个示例.
ASS files are more complicated structurally, but they allow more formatting options. Otherwise, you can use the force_style
option in the subtitles filter. Search this site for several examples.
这篇关于FFMPEG:使用drawtext以及自动换行和填充来创建视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!