【问题标题】:I want to add a watermark and text using ffmpeg我想使用 ffmpeg 添加水印和文字
【发布时间】:2022-01-19 13:14:23
【问题描述】:

我是 ffmpeg 的新手。我想使用 PHP 在视频上添加文本和图像。
我可以正确添加图像,但我无法向其添加文本。

我的代码:

$command = "ffmpeg -i ".$dest_path." -i 2.jpeg ";
$command .= " -filter_complex \"[0:v][1:v]";
$command .= " overlay=25:25\""; 
$str = rand();
$result = hash("sha256", $str);
$command .= " -c:a copy video/".$result.".mp4";
system($command)

【问题讨论】:

  • 错误信息是什么? (显示 ffmpeg 命令的输出)。
  • 我没有错误但我不知道如何将图像和文本组合在一起
  • ffmpeg -i ".$dest_path." -vf "drawtext=fontfile=/path/to/font.ttf:text="aya":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 output.mp4 这是我在视频上添加文本的代码我可以将这两个代码组合在一起吗?
  • 请更新问题。人们不会阅读所有的 cmets。

标签: php ffmpeg


【解决方案1】:

在叠加层之后添加drawtext,用逗号分隔。

$command .= " overlay=25:25,drawtext=...\""; 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    相关资源
    最近更新 更多