首页 > 解决方案 > 将填充颜色添加到 none 或 alpha 0,在使用 ffmpeg-python 时返回渲染视频中的绿色背景

问题描述

我正在使用 ffmpeg-python(用 python 编写的 ffmpeg 的包装器)下面是提到的示例代码。

                     inp.filter_multi_output('split')[k]
                        .filter_('rotate', a=rotation, fillcolor='#00FF0000',  ow=f"rotw({rotation})", oh=f"roth({rotation})")
                        .filter_('scale', width=(i['width'] * Factors().factors['w_factor']), height=(i['height'] * Factors().factors['h_factor'])).filter('setsar', '1/1')
                        .setpts(f"PTS-STARTPTS+{i['showtime']}/TB")

标签: pythonpython-3.xffmpeg

解决方案


                   inp.filter_multi_output('split')[k]
                       .filter_('scale', width=(i['width'] * Factors().factors['w_factor']), height=(i['height'] * Factors().factors['h_factor'])).filter('setsar', '1/1')
                        .filter_('rotate', a=rotation, fillcolor='#00FF0000',  ow=f"rotw({rotation})", oh=f"roth({rotation})")
                        .setpts(f"PTS-STARTPTS+{i['showtime']}/TB")

只需在旋转之前应用缩放,问题就会得到解决。


推荐阅读