use Image.frombytes, pass int not float

This commit is contained in:
j 2016-06-16 02:47:34 +02:00
parent b3deeb1c19
commit 82ddda4fb7

View file

@ -27,8 +27,6 @@ class Video(object):
samplerate = 48000
def __init__(self, path, height, audio, video_callback, done_callback):
self.height = height
self.video = self.height > 0
self.audio = audio
@ -125,7 +123,10 @@ def video(path, height=96, info=None, framerate=FPS):
return
else:
first = False
if hasattr(Image, 'fromstring'):
yield Image.fromstring('RGB', (width, height), data)
else:
yield Image.frombytes('RGB', (width, height), data)
def audio(path, info=None, samplerate=48000, framerate=FPS):
depth = 2
@ -154,7 +155,6 @@ def audio(path, info=None, samplerate=48000, framerate=FPS):
stdout=subprocess.PIPE,
stderr=open('/dev/null', 'w'),
close_fds=True)
chunk = int(nbytes / framerate)
first = True
while True:
@ -167,7 +167,7 @@ def audio(path, info=None, samplerate=48000, framerate=FPS):
else:
first = False
audio = np.fromstring(data, dtype="int16")
audio = audio.reshape((len(audio)/channels,channels)).astype('float')
audio = audio.reshape((int(len(audio)/channels), channels)).astype('float')
yield audio
def rms(x, axis=None):