in common/visualization.py [0:0]
def read_video(filename, skip=0, limit=-1):
w, h = get_resolution(filename)
command = ['ffmpeg',
'-i', filename,
'-f', 'image2pipe',
'-pix_fmt', 'rgb24',
'-vsync', '0',
'-vcodec', 'rawvideo', '-']
i = 0
with sp.Popen(command, stdout = sp.PIPE, bufsize=-1) as pipe:
while True:
data = pipe.stdout.read(w*h*3)
if not data:
break
i += 1
if i > limit and limit != -1:
continue
if i > skip:
yield np.frombuffer(data, dtype='uint8').reshape((h, w, 3))