Zhen Ye commited on
Commit
bbef397
·
1 Parent(s): 955fa9e

Add granular logging for frame processing and ffmpeg

Browse files
Files changed (2) hide show
  1. inference.py +3 -0
  2. utils/video.py +5 -1
inference.py CHANGED
@@ -1309,6 +1309,7 @@ def run_inference(
1309
  except Exception as e:
1310
  logging.exception("Writer loop failed")
1311
  finally:
 
1312
  writer_finished = True
1313
 
1314
  writer_thread = Thread(target=writer_loop, daemon=True)
@@ -1332,6 +1333,8 @@ def run_inference(
1332
  queue_in.put((frames_fed, frame)) # Blocks if full
1333
  frames_fed += 1
1334
 
 
 
1335
  # Update total_frames to actual count so writer knows when to stop
1336
  if frames_fed != total_frames:
1337
  logging.info("Updating total_frames from %d to %d (actual fed)", total_frames, frames_fed)
 
1309
  except Exception as e:
1310
  logging.exception("Writer loop failed")
1311
  finally:
1312
+ logging.info("Writer loop finished. Wrote %d frames (target %d)", next_idx, total_frames)
1313
  writer_finished = True
1314
 
1315
  writer_thread = Thread(target=writer_loop, daemon=True)
 
1333
  queue_in.put((frames_fed, frame)) # Blocks if full
1334
  frames_fed += 1
1335
 
1336
+ logging.info("Feeder finished. Fed %d frames (expected %d)", frames_fed, total_frames)
1337
+
1338
  # Update total_frames to actual count so writer knows when to stop
1339
  if frames_fed != total_frames:
1340
  logging.info("Updating total_frames from %d to %d (actual fed)", total_frames, frames_fed)
utils/video.py CHANGED
@@ -50,7 +50,11 @@ def _transcode_with_ffmpeg(src_path: str, dst_path: str) -> None:
50
  ]
51
  process = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
52
  if process.returncode != 0:
53
- raise RuntimeError(process.stderr.decode("utf-8", errors="ignore"))
 
 
 
 
54
 
55
 
56
  def write_video(frames: List[np.ndarray], output_path: str, fps: float, width: int, height: int) -> None:
 
50
  ]
51
  process = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=False)
52
  if process.returncode != 0:
53
+ err_msg = process.stderr.decode("utf-8", errors="ignore")
54
+ logging.error("ffmpeg failed with code %d: %s", process.returncode, err_msg)
55
+ raise RuntimeError(err_msg)
56
+ else:
57
+ logging.info("ffmpeg success")
58
 
59
 
60
  def write_video(frames: List[np.ndarray], output_path: str, fps: float, width: int, height: int) -> None: