Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the volume of sound of a video in Python using moviepy?

I want to get the volume of sound of a video so I use the following:

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))] 

But I get these errors:

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

I am using IPython notebook and Python 2.7. I assume something doesn't have the appropriate permissions. I have changed run this program as an administrator for ffmpeg.exe, ffplay.exe, ffprobe.exe.

like image 406
IordanouGiannis Avatar asked Jan 23 '15 21:01

IordanouGiannis


1 Answers

I fixed a bug today that may have caused your problem, would you mind upgrading and trying again ? If it still doesn't work, I'll need to know your windows version.

like image 157
Zulko Avatar answered Oct 16 '22 22:10

Zulko