使用imageio.ffmpeg.download()时的弃用错误

时间:2019-02-21 09:10:35

标签: python-3.x opencv ffmpeg

我正在尝试使用python Opencv合并预录的视频。 但是导入时出现错误。

"Traceback (most recent call last):
  File "video.py", line 4, in <module>
    from moviepy. editor import VideoFileClip,concatenate_videoclips 
  File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/moviepy/editor.py", line 26, in <module>
    imageio.plugins.ffmpeg.download()
  File "/home/pi/.virtualenvs/cv/lib/python3.5/site-packages/imageio/plugins/ffmpeg.py", line 40, in download
    "imageio.ffmpeg.download() has been deprecated. "
RuntimeError: imageio.ffmpeg.download() has been deprecated. Use 'pip install imageio-ffmpeg' instead.'"

有人请帮助摆脱这个问题

代码如下:

import cv2 
import os 
import time 
from moviepy.editor import VideoFileClip,concatenate_videoclips 
def vidcapt():
    a = time.strftime("%H,%M,%S")
    cap = cv2.VideoCapture(0)
    fourcc = cv2.VideoWriter_fourcc(*'XVID')
    out = cv2.VideoWriter(a+'.avi', fourcc, 24.0, (640,480))
    t1 = time.time()
    while(cap.isOpened()):
            ret, frame = cap.read() 
            if ret == True:
                    out.write(frame)
                    cv2.imshow('frame',frame)
                    t2 = time.time()
                    time_diff = t2-t1
                    if time_diff >= 5:
                            break
            else:
                    break
    cap.release()
    out.release()
    cv2.destroyAllWindows()

while True:
        vidcapt()


clip1 = VideoFileClip("11,05,42.avi")
clip2 = VideoFileClip("11,05,47.avi").subclip(50,60)
final_clip = concatenate_videoclips([clip1,clip2])
final_clip.write_videofile("merged.avi")

2 个答案:

答案 0 :(得分:1)

尝试以下方法:

sudo pip3 install imageio==2.4.1

希望能解决您的问题。

答案 1 :(得分:0)

或者,只需在editor.py中注释这两行,它们引用了已经不推荐使用的函数

#if os.getenv('FFMPEG_BINARY', 'ffmpeg-imageio') == 'ffmpeg-imageio':
#    imageio.plugins.ffmpeg.download()