当我添加水印时,FFMPEG gif调整大小不起作用 [英] FFMPEG gif resizing not working while I am adding watermark

查看:2415
本文介绍了当我添加水印时,FFMPEG gif调整大小不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将视频大小调整为gif图像。但是每次我失败了。

I am trying to resize video to gif image. But everytime i am getting failure.

请检查我的cdde:

$input = "files/video.mp4";
$thumbnail = 'img/logo.png'
$output = 'gif/'.time().'.gif';

$command = "ffmpeg -t 3 -ss 00:00:02 -i $input -i $thumbnail -filter_complex overlay=W-w-5:H-h-5 -codec:a copy $output"
@exec($command, $ret);
print_r($ret);

以上命令我没有获取数组结果。但工作正常我的视频用水印成功转换为GIF。但是如果我试图调整下面的代码大小。此命令不工作。请告诉我哪里错误

Above command I am not getting array result. But working fine. My video successfully converted to GIF with watermark. But if I am trying to resize below code. This command not working. Please tell me where is error

$command = "ffmpeg -t 3 -ss 00:00:02 -i $input -vf scale=400:-1 -i $thumbnail -filter_complex overlay=W-w-5:H-h-5 -codec:a copy $output"

请帮助我。让我知道如果有任何其他方式使视频gif与调整大小和水印图像。

Please help me. Let me know if any other way to make video to gif with resize and watermark image.

编辑:如果我删除水印命令。然后我的调整大小的GIF工作正常。

If I am removing watermark command. Then my resize GIF working fine.

推荐答案

缩放也应该在复杂的内部。

The scaling should occur within the complex as well.

ffmpeg -t 3 -ss 00:00:02 -i $input -i $thumbnail -filter_complex [0]scale=400:-1[b];[b][1]overlay=W-w-5:H-h-5 -codec:a copy $output

否则单独的 vf 输出映射为ffmpeg输出。

Else the standalone vf output is mapped for output by ffmpeg.

FFmpeg提供用于优化GIF生成的palettegen和paletteuse过滤器。

FFmpeg offers palettegen and paletteuse filters for optimized GIF generation.

ffmpeg -t 3 -ss 00:00:02 -i $input -i $thumbnail -filter_complex [0]scale=400:-1[b];[b][1]overlay=W-w-5:H-h-5,split[v][p];[p]palettegen,fifo[pal];[v][pal]paletteuse -codec:a copy $output

这篇关于当我添加水印时,FFMPEG gif调整大小不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆