记录踩过的坑-moviepy

目录

moviepy报错:'NoneType' object has no attribute 'stdout'

MoviePy couldn't find the codec associated with the filename

moviepy编码器选择

moviepy剪裁的视频cv2读不出来


moviepy报错:'NoneType' object has no attribute 'stdout'

我用moviepy做视频裁剪,把音频去掉了即可,原因未研究。

write_videofile (xxxx, audio = False)

 

MoviePy couldn't find the codec associated with the filename

我用的是subclip然后write_videofile做裁剪,把一个视频裁成n个小视频。

但我保存的格式用的.avi,所以必须指定编码器。

可以将文件存为.mp4,这个时候则不用指定编码器。

 

moviepy编码器选择

libx264可以自动匹配原视频速率

mpeg4默认200kbps,可以自己指定。但比如我有10个不同速率的视频,就比较麻烦,无法批量处理。

质量上官方说法是mpeg4好,但说实话我看不出差别。

相对于mpeg4,libx264文件大小较小。

 

moviepy剪裁的视频cv2读不出来

video.subclip(t, t+3).write_videofile(join(outpath, outname), fps=25, codec="mpeg4")

video.subclip(t, t+3).write_videofile(join(outpath, outname), fps=25, codec="png")

png格式cv2读不出来

videoCapture = cv2.VideoCapture(video_file)

用mpeg4可以


版权声明:本文为ytomc原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。