Moviepy concatenate_videoclips(method ='compose')AttributeError:'NoneType'对象没有属性'stdout'

时间:2019-12-26 18:03:39

标签: python moviepy

我正在编写将短片合并到视频中的脚本,但是这些视频包含不同的大小和帧频。当我运行下面的代码时,输​​出的视频充满了第二个剪辑的毛刺。

from moviepy.editor import *

clips = [ VideoFileClip("clips/clip-1.mp4"),
VideoFileClip("clips/clip-2.mp4"),
VideoFileClip("clips/clip-3.mp4")]

final_clip = concatenate_videoclips(clips)
final_clip.write_videofile("final.mp4")`

搜索更好,我认为这可能是因为它们的属性不同,所以我包含了compose()方法:

final_clip = concatenate_videoclips(clips, method='compose')

并出现以下错误:

File "c:/video machine/test.py", line 8, in <module> final_clip.write_videofile("final.mp4") 
File "<C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\decorator.py:decorator-gen-51>", line 2, in write_videofile 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration return f(clip, *a, **k) 
File "<C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\decorator.py:decorator-gen-50>", line 2, in write_videofile 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default return f(clip, *new_a, **new_kw) 
File "<C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\decorator.py:decorator-gen-49>", line 2, in write_videofile 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB return f(clip, *a, **k) 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\video\VideoClip.py", line 317, in write_videofile logger=logger) 
File "<C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\decorator.py:decorator-gen-73>", line 2, in write_audiofile 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration return f(clip, *a, **k) 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\AudioClip.py", line 209, in write_audiofile logger=logger) File "<C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\decorator.py:decorator-gen-70>", line 2, in ffmpeg_audiowrite File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 169, in ffmpeg_audiowrite logger=logger): File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\AudioClip.py", line 85, in iter_chunks fps=fps, buffersize=chunksize) File "<C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\decorator.py:decorator-gen-72>", line 2, in to_soundarray File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration return f(clip, *a, **k) File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\AudioClip.py", line 126, in to_soundarray snd_array = self.get_frame(tt) File "<C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\decorator.py:decorator-gen-10>", line 2, in get_frame File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\decorators.py", line 89, in wrapper return f(*new_a, **new_kw) File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\Clip.py", line 95, in get_frame return self.make_frame(t) File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\AudioClip.py", line 296, in make_frame for c, part in zip(self.clips, played_parts) File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\AudioClip.py", line 297, in <listcomp> if (part is not False)] File "<C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\decorator.py:decorator-gen-10>", line 2, in get_frame File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\decorators.py", line 89, in wrapper return f(*new_a, **new_kw) File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\Clip.py", line 95, in get_frame return self.make_frame(t) File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\AudioFileClip.py", line 78, in <lambda> self.make_frame = lambda t: self.reader.get_frame(t) 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\readers.py", line 184, in get_frame self.buffer_around(fr_max) 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\readers.py", line 238, in buffer_around array = self.read_chunk(chunksize) 
File "C:\Users\LT1Kqob5UDEML61gCyjnAcfMXgkdP3wGcg45UBcFon37-32\lib\site-packages\moviepy\audio\io\readers.py", line 112, in read_chunk s = self.proc.stdout.read(L) 
AttributeError: 'NoneType' object has no attribute 'stdout

电影版本:1.0.1

1 个答案:

答案 0 :(得分:0)

我认为这是moviepy中的一个开放错误,请尝试安装1.0.0版

public class SrcParent
{
    public int Id { get; set; }
    public List<SrcChild> SrcChildren { get; set; }
}

public class SrcChild
{
    public int Id { get; set; }
    public int SrcParentId { get; set; }
    public string Name { get; set; }
    public string Value { get; set; }
}

public class DstParent
{
    public int Id { get; set; }
    public int ConfigurationId { get; set; }
    public List<DstChild> DstChildren { get; set; }
}

public class DstChild
{
    public int Id { get; set; }
    public int DstParentId { get; set; }
    public string Name { get; set; }
    public string Value { get; set; }
}

this.CreateMap<SrcParent, DstParent>()
    .ForMember(dst => dst.Id, opt => opt.Ignore())
    .ForMember(dst => dst.ConfigurationId, opt => opt.Ignore())
    .ForMember(dst => dst.DstChildren, opt => opt.MapFrom<MyValueResolver>());

public class MyValueResolver : IValueResolver<SrcParent, DstParent, List<DstChild>>
{
    public List<DstChild> Resolve(SrcParent source, DstParent destination, List<DstChild> destMember, ResolutionContext context)
    {
        /*
         * Many expensive operations that can be safely cached
         * on the resolver instance through the lifetime.
         */
    }
}

// Seed the mapper with an existing instance to hint the child conversion.
var dst = new DstParent
{
    ConfigurationId = 42
};

this.mapper.Map(src, dst);