[英]How can I get the volume of sound of a video in Python using moviepy?
我想獲得視頻的音量,所以我使用以下內容:
import numpy as np # for numerical operations
from moviepy.editor import VideoFileClip, concatenate
clip = VideoFileClip("soccer_game.mp4")
cut = lambda i: clip.audio.subclip(i,i+1).to_soundarray(fps=22000)
volume = lambda array: np.sqrt(((1.0*array)**2).mean())
volumes = [volume(cut(i)) for i in range(0,int(clip.audio.duration-2))]
但我得到這些錯誤:
Exception AttributeError: "VideoFileClip instance has no attribute 'reader'" in <bound method VideoFileClip.__del__ of <moviepy.video.io.VideoFileClip.VideoFileClip instance at 0x084C3198>> ignored
WindowsError: [Error 5] Access is denied
我正在使用 IPython 筆記本和 Python 2.7。 我認為某些東西沒有適當的權限。 我更改了以管理員身份運行該程序的 ffmpeg.exe、ffplay.exe、ffprobe.exe。
我今天修復了一個可能導致您的問題的錯誤,您介意升級並重試嗎? 如果它仍然不起作用,我需要知道你的 windows 版本。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.