Skip to content

Commit

Permalink
add video variables to init.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgineer85 committed Feb 3, 2024
1 parent 689024e commit b650d1a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions photobooth/services/backends/picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ def __init__(self):
self._lores_data: __class__.PicamLoresData = None
self._hires_data: __class__.PicamHiresData = None

# video related variables. picamera2 uses local recording implementation and overrides abstractbackend
self._video_recorded_videofilepath = None
self._video_encoder = None
self._video_output = None

# worker threads
self._worker_thread: StoppableThread = None

Expand Down Expand Up @@ -240,7 +245,7 @@ def _wait_for_lores_image(self):

def start_recording(self):
self._video_recorded_videofilepath = Path("tmp", f"{self.__class__.__name__}_{uuid.uuid4().hex}").with_suffix(".mp4")
self._video_encoder = H264Encoder(appconfig.misc.video_bitrate)
self._video_encoder = H264Encoder(appconfig.misc.video_bitrate * 1000) # bitrate in k in appconfig, so *1000
self._video_output = FfmpegOutput(str(self._video_recorded_videofilepath))

self._picamera2.start_encoder(self._video_encoder, self._video_output, name="lores")
Expand All @@ -255,7 +260,6 @@ def stop_recording(self):
logger.info("no picamera2 video encoder active that could be stopped")

def get_recorded_video(self) -> Path:
# basic idea from https://stackoverflow.com/a/42602576
if self._video_recorded_videofilepath is not None:
out = self._video_recorded_videofilepath
self._video_recorded_videofilepath = None
Expand Down

0 comments on commit b650d1a

Please sign in to comment.