Camera: fix VFR video timestamps and close ffmpeg stderr
CI / test (push) Failing after 49s

- Pass -enc_time_base demux to ffmpeg so VFR video keeps the source timing
- Read the encoder's stderr only on failure, and always close the pipe
- Mirror the same ffmpeg flag and stderr close in test_camera.py
This commit is contained in:
nandi committed 2026-11-28 19:28:05 -08:00
1 parent 52b42890d6
commit 6cb0562654
2 files changed
+12 -1

No files matched your search

+10 -1
View File
@@ -2019,6 +2019,8 @@ class CameraEngine:
"-",
"-fps_mode",
"passthrough",
"-enc_time_base",
"demux",
"-video_track_timescale",
"1000",
"-c:v",
@@ -2163,10 +2165,17 @@ class CameraEngine:
if wt is not None:
wt.join(timeout=15.0)
rc = proc.wait(timeout=15.0)
if rc != 0 and proc.stderr is not None:
if proc.stderr is not None:
try:
if rc != 0:
err = proc.stderr.read().decode("utf-8", "replace").strip()
if err and self.on_error:
self.on_error("Video encode error: " + err)
finally:
try:
proc.stderr.close()
except Exception:
pass
return path, frames
+2
View File
@@ -304,6 +304,7 @@ class TestCameraHelpers(unittest.TestCase):
"ffmpeg", "-y", "-loglevel", "error",
"-f", "matroska", "-i", "-",
"-fps_mode", "passthrough",
"-enc_time_base", "demux",
"-video_track_timescale", "1000",
"-c:v", "libx264", "-preset", "superfast", "-crf", "22", "-bf", "0",
"-pix_fmt", "yuv420p",
@@ -315,6 +316,7 @@ class TestCameraHelpers(unittest.TestCase):
proc.stdin.close()
rc = proc.wait(timeout=15)
err = proc.stderr.read().decode("utf-8", "replace")
proc.stderr.close()
self.assertEqual(rc, 0, msg="ffmpeg failed: " + err)
info = json.loads(subprocess.check_output([