首页 > 编程语言 >程序遇坑

程序遇坑

时间:2023-03-13 21:58:40浏览次数:47  
标签:cnt return parent 遇坑 newname 程序 decode file

1.movie.py
editor.CompositeVideoClip 报错
安装 ImageMagick
修改环境变量为程序路径 IMAGEMAGICK_BINARY="C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\magick.exe"
程序 https://wwru.lanzouf.com/isWOA0pofhbi
原始地址 http://www.imagemagick.org/script/download.php#windows

基础使用教程 https://www.cnblogs.com/traditional/p/11144123.html

2.文件编码出错
'utf-8' codec can't decode byte 0xe3 in position 1973: invalid continuation byte
修改模块内部代码 位置 moviepy\video\io\ffmpeg_reader.py
try:
infos = error.decode('utf8')
except Exception as e:
infos = error.decode('ANSI',errors='ignore')
3.文件不存在 文件名有问题
硬链接到临时文件,函数返回视频对象,时间点百分比确定为实际时间点

点击查看代码
 def shot_sth(self,file,t,cnt=1):
        try:
            v= editor.VideoFileClip(str(file))  
            if isinstance(t,str ) and '%' in t:
                t=v.duration*int(t.replace('%',''))//100
        except:
            if cnt==1:
                # 意外硬链接随即名再试一次
                newname=Path(file).parent.parent.joinpath('temphd',f'{random.random()}'+Path(file).suffix)
                dir_make(newname.parent)
                os.link(file,newname)
                r=self.shot_sth(newname,t,cnt=0)
                if r:
                    return r
            return
        return v,int(t)

标签:cnt,return,parent,遇坑,newname,程序,decode,file
From: https://www.cnblogs.com/adenosine/p/17198920.html

相关文章