Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Sometimes it is useful to know the total number of video frames before starting to iterate.
- This is not possible using the default video reader in Sk-video.
- The snippet below shows how to do this using the FFMPEG reader instead.
- '''
- if osp.exists(video_path):
- vid_reader = skvideo.io.FFmpegReader(video_path) # NOTE: not the standard skvideo.io.vreader
- else:
- raise IOError('Path to video not found: \n%s' % video_path)
- # Knowing number of frames from FFMPEG metadata w/o without iterating over all frames
- (numframe, _, _, _) = vid_reader.getShape() # numFrame x H x W x channels
- videogen = vid_reader.nextFrame() # generator for iterating over all video frames
Add Comment
Please, Sign In to add comment