- 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:
1 parent
52b42890d6
commit
6cb0562654
2 files changed
+15
-4
No files matched your search
+13
-4
@@ -2019,6 +2019,8 @@ class CameraEngine:
|
|||||||
"-",
|
"-",
|
||||||
"-fps_mode",
|
"-fps_mode",
|
||||||
"passthrough",
|
"passthrough",
|
||||||
|
"-enc_time_base",
|
||||||
|
"demux",
|
||||||
"-video_track_timescale",
|
"-video_track_timescale",
|
||||||
"1000",
|
"1000",
|
||||||
"-c:v",
|
"-c:v",
|
||||||
@@ -2163,10 +2165,17 @@ class CameraEngine:
|
|||||||
if wt is not None:
|
if wt is not None:
|
||||||
wt.join(timeout=15.0)
|
wt.join(timeout=15.0)
|
||||||
rc = proc.wait(timeout=15.0)
|
rc = proc.wait(timeout=15.0)
|
||||||
if rc != 0 and proc.stderr is not None:
|
if proc.stderr is not None:
|
||||||
err = proc.stderr.read().decode("utf-8", "replace").strip()
|
try:
|
||||||
if err and self.on_error:
|
if rc != 0:
|
||||||
self.on_error("Video encode error: " + err)
|
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
|
return path, frames
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -304,6 +304,7 @@ class TestCameraHelpers(unittest.TestCase):
|
|||||||
"ffmpeg", "-y", "-loglevel", "error",
|
"ffmpeg", "-y", "-loglevel", "error",
|
||||||
"-f", "matroska", "-i", "-",
|
"-f", "matroska", "-i", "-",
|
||||||
"-fps_mode", "passthrough",
|
"-fps_mode", "passthrough",
|
||||||
|
"-enc_time_base", "demux",
|
||||||
"-video_track_timescale", "1000",
|
"-video_track_timescale", "1000",
|
||||||
"-c:v", "libx264", "-preset", "superfast", "-crf", "22", "-bf", "0",
|
"-c:v", "libx264", "-preset", "superfast", "-crf", "22", "-bf", "0",
|
||||||
"-pix_fmt", "yuv420p",
|
"-pix_fmt", "yuv420p",
|
||||||
@@ -315,6 +316,7 @@ class TestCameraHelpers(unittest.TestCase):
|
|||||||
proc.stdin.close()
|
proc.stdin.close()
|
||||||
rc = proc.wait(timeout=15)
|
rc = proc.wait(timeout=15)
|
||||||
err = proc.stderr.read().decode("utf-8", "replace")
|
err = proc.stderr.read().decode("utf-8", "replace")
|
||||||
|
proc.stderr.close()
|
||||||
self.assertEqual(rc, 0, msg="ffmpeg failed: " + err)
|
self.assertEqual(rc, 0, msg="ffmpeg failed: " + err)
|
||||||
|
|
||||||
info = json.loads(subprocess.check_output([
|
info = json.loads(subprocess.check_output([
|
||||||
|
|||||||
Reference in new issue
Block a user