Moviepy write_videofile с массивом в concatenate_videoclips приводит к AttributeError - PullRequest
0 голосов
/ 03 апреля 2019

Я пытаюсь отредактировать кучу видео, для этого я записываю их все из списка в один массив, а затем редактирую их все вместе в одно с concatenate_videoclips.

Кажется, это работает, но когда я пытаюсь написать этот файл, я получаю AttributeError из VideoFileClip.py

Вот что я попробовал:

import moviepy.editor as mp

videostoedit = []
currenque = {"File1" : "File1",
             "File2" : "File2",
             "File3" : "File3"}

for z in currentque:
    video = mp.VideoFileClip(z + '/output.mp4')
    videostoedit.append(video)
    video.close()

tempvideo = mp.concatenate_videoclips([i for i in videostoedit], method="compose")
tempvideo.write_videofile('video.mp4', write_logfile=True, fps=60, codec='libx264')
tempvideo.close()

Я получаю эту ошибку при попытке записать временное видео:

t:   0%|                                                                           | 0/21197 [00:00<?, ?it/s, now=None]Traceback (most recent call last):
  File "C:\Users\Username\source\repos\Sandbox\Sandbox\Video.py", line 62, in <module>
    tempvideo.write_videofile(temp_filelocation + '/video.mp4', write_logfile=True, fps=60, codec='libx264')
  File "<C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\decorator.py:decorator-gen-51>", line 2, in write_videofile
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\decorator.py:decorator-gen-50>", line 2, in write_videofile
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\decorators.py", line 137, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\decorator.py:decorator-gen-49>", line 2, in write_videofile
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\video\VideoClip.py", line 326, in write_videofile
    logger=logger)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 216, in ffmpeg_write_video
    fps=fps, dtype="uint8"):
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\Clip.py", line 475, in iter_frames
    frame = self.get_frame(t)
  File "<C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\decorator.py:decorator-gen-10>", line 2, in get_frame
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\video\compositing\CompositeVideoClip.py", line 118, in make_frame
    f = c.blit_on(f, t)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\video\VideoClip.py", line 548, in blit_on
    img = self.get_frame(ct)
  File "<C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\decorator.py:decorator-gen-10>", line 2, in get_frame
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\Clip.py", line 95, in get_frame
    return self.make_frame(t)
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 113, in <lambda>
    self.make_frame = lambda t: self.reader.get_frame(t)
AttributeError: 'NoneType' object has no attribute 'get_frame'

Вот журнал ошибок от операции записи:

ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8.2.1 (GCC) 20181017
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, rawvideo, from 'pipe:':
  Duration: N/A, bitrate: 2985984 kb/s
    Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1920x1080, 2985984 kb/s, 60 tbr, 60 tbn, 60 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
[libx264 @ 000001e3144ce300] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 000001e3144ce300] profile High, level 4.2, 4:2:0, 8-bit
[libx264 @ 000001e3144ce300] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'Y:/video.mp4':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080, q=-1--1, 60 fps, 15360 tbn, 60 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=00:00:00.00 bitrate=N/A speed=   0x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Все видео в Списке созданы другим Сценарием с этим:

    resizedvideo = video.resize((1920,1080))
    resizedvideo.write_videofile(nameoffile, audio='a.mp4', fps=60, codec='libx264', audio_codec='libfdk_aac')

Все видео хранятся в разных папках, и пути к ним сохраняются с уникальным идентификатором в списке.

В чем может быть причина этой ошибки? Я не могу понять это сам.

Я благодарен за всю помощь, которую я могу получить.

...