Skip to content

Commit

Permalink
Check video validity early on.
Browse files Browse the repository at this point in the history
Preliminary check to protect users against #557.
  • Loading branch information
jeylau committed Jan 21, 2020
1 parent e6eecc3 commit 2e6a70d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion deeplabcut/pose_estimation_tensorflow/predict_videos.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,8 @@ def AnalyzeVideo(video,DLCscorer,DLCscorerlegacy,trainFraction,cfg,dlc_cfg,sess,
if notanalyzed:
print("Loading ", video)
cap=cv2.VideoCapture(video)

if not cap.isOpened():
raise IOError('Video could not be opened. Please check that the path is valid.')
fps = cap.get(5) #https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get
nframes = int(cap.get(7))
duration=nframes*1./fps
Expand Down

0 comments on commit 2e6a70d

Please sign in to comment.