chenjoya commited on
Commit
9356aac
·
verified ·
1 Parent(s): 05b1e58

Update demo/infer.py

Browse files
Files changed (1) hide show
  1. demo/infer.py +6 -2
demo/infer.py CHANGED
@@ -76,14 +76,18 @@ class LiveCCDemoInfer:
76
  """
77
  # 1. preparation: video_reader, and last processing info
78
  video_timestamp, last_timestamp = state.get('video_timestamp', 0), state.get('last_timestamp', -1 / self.fps)
79
- video_path = state['video_path']
 
 
80
  if video_path not in self._cached_video_readers_with_hw:
81
  self._cached_video_readers_with_hw[video_path] = get_smart_resized_video_reader(video_path, max_pixels)
82
  video_reader = self._cached_video_readers_with_hw[video_path][0]
83
  video_reader.get_frame_timestamp(0)
84
  state['video_pts'] = torch.from_numpy(video_reader._frame_pts[:, 1])
85
  state['last_video_pts_index'] = -1
86
- video_pts = state['video_pts']
 
 
87
  video_timestamp = min(video_timestamp, video_pts[-1])
88
  if last_timestamp + self.frame_time_interval > video_pts[-1]:
89
  state['video_end'] = True
 
76
  """
77
  # 1. preparation: video_reader, and last processing info
78
  video_timestamp, last_timestamp = state.get('video_timestamp', 0), state.get('last_timestamp', -1 / self.fps)
79
+ video_path = state.get('video_path', None)
80
+ if not video_path:
81
+ return
82
  if video_path not in self._cached_video_readers_with_hw:
83
  self._cached_video_readers_with_hw[video_path] = get_smart_resized_video_reader(video_path, max_pixels)
84
  video_reader = self._cached_video_readers_with_hw[video_path][0]
85
  video_reader.get_frame_timestamp(0)
86
  state['video_pts'] = torch.from_numpy(video_reader._frame_pts[:, 1])
87
  state['last_video_pts_index'] = -1
88
+ video_pts = state.get('video_pts', None)
89
+ if not video_pts:
90
+ return
91
  video_timestamp = min(video_timestamp, video_pts[-1])
92
  if last_timestamp + self.frame_time_interval > video_pts[-1]:
93
  state['video_end'] = True