繁体   English   中英

上传时的ffmpeg水印视频

[英]ffmpeg watermark video while uploading

我有一个使用 ffmpeg 上传视频的 CMS 系统,每次出现错误(视频无法播放)或错误编码等时,我都无法想办法为视频添加水印。处理视频的命令是:

$shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=426:-2 -crf 26 $video_output_full_path_240 2>&1");

我也试过这个命令:

$shell     = shell_exec("$ffmpeg_b -y -i $video_file_full_path -vcodec libx264 -preset {$pt->config->convert_speed} -filter:v scale=426:-2 -crf 26 -i watermark.png -filter_complex 'overlay=10:10' $video_output_full_path_240 2>&1");

这似乎不起作用..有什么办法可以解决这个问题吗?

问题

如果您要参考ffmpeg的输出,您会遇到两个错误:

  • 选项filter:v (set stream filtergraph) 不能应用于输入 url watermark.png - 您正在尝试将输入选项应用于输出文件,反之亦然。 将此选项移动到它所属的文件之前。 解析输入文件watermark.png选项时出错。

  • Filtergraph 'scale=426:-2'是通过-vf / -af / -filter选项为输出流 0:0 指定的,它是从复杂的 filtergraph 馈送的。 -vf / -af / -filter-filter_complex不能一起用于同一个流。

解决方案

  • 期权安置很重要。 您正在混合输入和输出选项的放置。 放置必须如下:
    ffmpeg [global options] [input0 options] -i input0 [input1 options] -i input1 [output options] output
  • 不要混合使用-vf-filter_complex 在一个-filter_complex实例中完成所有过滤。

例子

ffmpeg -i video.mp4 -i watermark.png -filter_complex "[0]scale=426:-2[bg];[bg][1]overlay=10:10" -c:v libx264 -preset fast -crf 26 output.mp4

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM