我想将带有 Alpha 通道的 .avi 转换为 .gif。
首先,我使用
ffmpeg -i source.avi -vf scale=720:-1:flags=lanczos,fps=10 frames/ffout%03d.png
将 .avi 转换为带有 Alpha 通道的 .png 序列。
然后,我用
gm convert -loop 0 frames/ffout*.png output.gif
收集 .gif。
但当不透明的东西渲染在透明区域之上时,output.gif 的像素似乎会被卡住。
这是一个例子:
![img](https://i.stack.imgur.com/M7fAM.gif)
正如你所看到的,红心和爆炸并没有被渲染。
附:
FFMPEG 输出(.png 的集合)很好。
我不使用 Graphicsmagick 但你的GIF有图像处置方式 0
(无动画)。你应该使用处置方式 2
(背景清晰)或3
(恢复以前的图像)两者都适合您GIF。该处理存在于每个帧的 gfx 扩展中Packed
value.
因此,如果您可以尝试配置编码器以使用disposal = 2
or 3
或者编写直接流复制您的脚本GIF并改变Packed
gfx 扩展块逐帧的值。与此类似:
如果您需要脚本方面的帮助,请查看:
- 如何找到GIF图像中图像块从哪里开始?
- 解码 GIF87a 光栅数据流的数据字节
当我尝试这个时(C++脚本)在你的GIF使用处置2
我得到这个结果:
![disposal=2](https://i.stack.imgur.com/GVIzA.gif)
处置方式发生变化C++像这样:
struct __gfxext
{
BYTE Introducer; /* Extension Introducer (always 21h) */
BYTE Label; /* Graphic Control Label (always F9h) */
BYTE BlockSize; /* Size of remaining fields (always 04h) */
BYTE Packed; /* Method of graphics disposal to use */
WORD DelayTime; /* Hundredths of seconds to wait */
BYTE ColorIndex; /* Transparent Color Index */
BYTE Terminator; /* Block Terminator (always 0) */
__gfxext(){}; __gfxext(__gfxext& a){ *this=a; }; ~__gfxext(){}; __gfxext* operator = (const __gfxext *a) { *this=*a; return this; }; /*__gfxext* operator = (const __gfxext &a) { ...copy... return this; };*/
};
__gfxext p;
p.Packed&=255-(7<<2); // clear old disposal and leave the rest as is
p.Packed|= 2<<2; // set new disposal=2 (the first 2 is disposal , the <<2 just shifts it to the correct position in Packed)
留下其他部分是个好主意Packed
因为没有人知道可以及时在其中编码什么......
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)