使用ffmpeg在视频上添加文本时出错

时间:2018-03-05 18:18:55

标签: ffmpeg protocols watermark

我尝试使用ffmpeg在视频上添加文字。如果单词中没有间距,一切都很好。这是我的代码

$text = "Robert Tamunoemi";
$cmd = 'ffmpeg -i '.$videoPath.'  -vcodec libx264 -f mp4 -vf drawtext="fontfile=fonts/futura-normal.ttf:text="'.$text.'":fontcolor=black@1.0:fontsize=14:x=00: y=40" -preset medium  videos/birds.mp4';

shell_exec($cmd.' 2> log.txt');

这是ffmpeg log

的输出
ffmpeg version N-89674-g57d0c24132 Copyright (c) 2000-2018 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-libopencore-amrnb --enable-libopencore-amrwb --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-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-amf --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
  libavutil      56.  7.100 / 56.  7.100
  libavcodec     58.  9.100 / 58.  9.100
  libavformat    58.  3.100 / 58.  3.100
  libavdevice    58.  0.100 / 58.  0.100
  libavfilter     7.  8.100 /  7.  8.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 'videos/pest11.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.3.100
  Duration: 00:00:18.20, start: 0.000000, bitrate: 223 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x584 [SAR 1:1 DAR 160:73], 83 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 132 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Tamunoemi:fontcolor=black@1.0:fontsize=14:x=00: y=40: Protocol not found

1 个答案:

答案 0 :(得分:1)

试试这个:

ffmpeg -i videos/test3.mp4 -vcodec libx264 -f mp4 -vf drawtext='fontfile=fonts/futura-normal.ttf:text="Robert Tamunoemi":fontcolor=black@1.0:fontsize=14:x=00:y=40' -preset medium videos/birds.mp4