【问题标题】:Text on video using FFMPEG使用 FFMPEG 的视频文本
【发布时间】:2018-05-06 00:31:40
【问题描述】:

我正在尝试使用 ffmpeg 在视频上添加文本。我在stackoverflow中看到了很多帮助并遵循了,但运气不好我无法成功。

我已关注this thread

这是我的命令

ffmpeg -i C:/source/TestScene.mov -vf drawtext="fontfile=c:/windows/fonts/arial.ttf: text='TestMessage': fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2" -codec:a copy C:/source/TestScene_test.mov

这是我的错误回溯

F:\SW\ffmpeg\bin>ffmpeg -i C:/source/TestScene.mov -vf drawtext="fontfile=c:/windows/fonts/arial.ttf: text='TestMessage': fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2" -codec:a copy C:/source/TestScene_test.mov
ffmpeg version N-89127-g8f4702a93f Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
  libavutil      56.  0.100 / 56.  0.100
  libavcodec     58.  3.103 / 58.  3.103
  libavformat    58.  2.100 / 58.  2.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  2.100 /  7.  2.100
  libswscale      5.  0.101 /  5.  0.101
  libswresample   3.  0.101 /  3.  0.101
  libpostproc    55.  0.100 / 55.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/source/TestScene.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf58.2.100
  Duration: 00:00:04.67, start: 0.000000, bitrate: 187 kb/s
    Stream #0:0(eng): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 1280x720, 185 kb/s, 24 fps, 24 tbr, 12288 tbn, 48 tbc (default)
    Metadata:
      handler_name    : DataHandler
      encoder         : Lavc58.3.103 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Press [q] to stop, [?] for help
Fontconfig error: Cannot load default config file
[Parsed_drawtext_0 @ 0000009cfe42ef20] Cannot find a valid font for the family Sans
[AVFilterGraph @ 0000009cfed15fc0] Error initializing filter 'drawtext' with args 'fontfile=c:/windows/fonts/arial.ttf: text=TestMessage: fontcolor=white: fontsize=24: box=1: boxcolor=black@0.5: boxborderw=5: x=(w-text_w)/2: y=(h-text_h)/2'
Error reinitializing filters!
Failed to inject frame into filter network: No such file or directory
Error while processing the decoded data for stream #0:0
Conversion failed!

希望看到一些解决方案。

【问题讨论】:

    标签: ffmpeg


    【解决方案1】:

    您必须转义字体路径并将其显示为字符串:

    fontfile='c\:\/windows\/fonts\/arial.ttf'
    

    【讨论】:

    • 即使通过转义字体路径我也会收到此错误“[Parsed_drawtext_0 @ 0000003803a5bee0] 找不到适用于 Sans 系列的有效字体”
    • 即使没有 fontfile='c\:\/windows\/fonts\/arial.ttf' 我也会遇到同样的错误
    • 它通过将字体文件路径保留为我错过的字符串来解决。但是你把它保存为字符串。正如你在回复中提到的只是转义字符我只看了这一点,无论如何你解决了我的问题。我要求您编辑您的答案,以将字体路径保留为字符串表示法。我会接受它作为答案,所以它也会对其他人有所帮助。
    • 终于!这种表示法奏效了。我尝试了从 \\\ 到任何东西的一切。这对其进行了排序:)
    • 对于 OSX,您可以使用 fontfile=/System/Library/Fonts/SFNSMono.ttf
    猜你喜欢
    • 2022-06-14
    • 1970-01-01
    • 2017-12-23
    • 2019-12-24
    • 2020-05-23
    • 2013-05-22
    • 2019-01-04
    • 2017-10-05
    • 2013-07-11
    相关资源
    最近更新 更多