【问题标题】:FFMPEG: Creating video using drawtext along with word wrap and paddingFFMPEG:使用drawtext以及自动换行和填充创建视频
【发布时间】:2018-05-31 15:51:48
【问题描述】:

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

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

下面是我用来从文本生成视频的 sn-p

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

输出如下所示

【问题讨论】:

    标签: video ffmpeg


    【解决方案1】:

    请改用subtitles filter

    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 选项。在这个网站上搜索几个例子。

    【讨论】:

    猜你喜欢
    • 2016-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-20
    • 2010-12-26
    相关资源
    最近更新 更多