def _get_duration(filename) : command = ['ffprobe', '-v', 'error', '-show_entries', 'format=duration', '-of', 'default=noprint_wrappers=1:nokey=1', filename, '-sexagesimal'] ffmpeg = subprocess.Popen(command, stderr=subprocess.PIPE ,stdout = subprocess.PIPE ) out, err = ffmpeg.communicate() if(err) : print(err) return out def _read_frame(filename,time) : command = ['ffmpeg', '-loglevel', 'error', '-ss', str(time), #from this time '-i', filename, '-vframes', str(1), #get single frame '-f', 'image2pipe', '-pix_fmt', 'rgb24', '-vcodec', 'rawvideo', '-'] #print(command) ffmpeg = subprocess.Popen(command, stderr=subprocess.PIPE ,stdout = subprocess.PIPE ) out, err = ffmpeg.communicate() if(err) : print(err) image = np.fromstring(out, dtype='uint8').reshape((960,1280,3)) return image