moviepy.editor为什么报错,PyQt封装时软件报错解决方法

最近在使用用moviepy写一个视频转gif的程序,中间遇到了两个很多人遇到的问题。

1、moviepy.editor报错

这个和moviepy版本有关系,升级到最新版本之后,这个方法已经被弃用了。所以会报错,

以前是from moviepy.editor import VideoFileClip

升级之后用是这样导入的:

from moviepy import VideoFileClip

可以去看下官方的最新版本的介绍文档

2、关于封装封装后报错的原因

我的程序界面是这样的:

封装之后,就展示数据执行状态,和运行日志,在运行日志中,会打印出需要查看的日志信息,但是moviepy会调用的 dos窗口展示一个进度条,不管是视频合成还是视频转gif,write方法下面会有一个logger字段,这个是进度条,默认值:bar,也就是展示进度条,可以看下下面的方法:

    @requires_duration
    @convert_masks_to_RGB
    @convert_path_to_string("filename")
    def write_gif(
        self,
        filename,
        fps=None,
        loop=0,
        logger="bar",
    ):
        """Write the VideoClip to a GIF file.

        Converts a VideoClip into an animated GIF using imageio

        Parameters
        ----------

        filename
          Name of the resulting gif file, as a string or a path-like object.

        fps
          Number of frames per second (see note below). If it
          isn't provided, then the function will look for the clip's
          ``fps`` attribute (VideoFileClip, for instance, have one).

        loop : int, optional
          Repeat the clip using ``loop`` iterations in the resulting GIF.

        progress_bar
          If True, displays a progress bar


        Notes
        -----

        The gif will be playing the clip in real time (you can
        only change the frame rate). If you want the gif to be played
        slower than the clip you will use

        .. code:: python

            # slow down clip 50% and make it a gif
            myClip.multiply_speed(0.5).to_gif('myClip.gif')

        """
        # A little sketchy at the moment, maybe move all that in write_gif,
        #  refactor a little... we will see.

        write_gif_with_imageio(
            self,
            filename,
            fps=fps,
            loop=loop,
            logger=logger,
        )

当我们调用这个方法的时候,会调用dos,如果调用不到就会报错。

解决办法:logger=None

sub_clip.write_gif(output_path, fps=10, logger=None)

我们在调用这个方法的时候,logger设置成None,再进行封装 ,这是软件就可以正常运行了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

淘小白_TXB2196

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值