Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.

Commit cbc0dd1

Browse files
committed
audio
1 parent 89c1a94 commit cbc0dd1

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/camera4kivy/based_on_kivy_core/camera/camera_picamera2.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def __init__(self):
162162
self.zoom_level = None
163163
self._rotate = 0
164164
self.video_recording = False
165+
self.audio = False
165166

166167
# Start
167168
# Choose sensor, configure pc2
@@ -377,7 +378,7 @@ def video_start(self, filepath, callback):
377378
self.picam2.switch_mode(self.video_config)
378379
encoder = H264Encoder()
379380
output = FfmpegOutputPlus(filepath, rotate = self._rotate,
380-
audio=True, audio_sync = 0)
381+
audio= self.audio, audio_sync = 0)
381382
self.picam2.start_encoder(encoder, output)
382383

383384
def video_stop(self):
@@ -476,6 +477,7 @@ def __init__(self, **kwargs):
476477
self.started = False
477478
self.fbo = None
478479
self._rotate = kwargs.get('rotation', 0)
480+
self.audio = kwargs.get('audio', False)
479481
super().__init__(**kwargs)
480482

481483
# Lifecycle
@@ -512,6 +514,7 @@ def start(self):
512514
self._camera._framerate = self._framerate
513515
self._camera._context = self._context
514516
self._camera._rotate = self._rotate
517+
self._camera.audio = self.audio
515518
self._texture = None
516519
if self._update_ev is not None:
517520
self._update_ev.cancel()

src/camera4kivy/preview_kivycamera.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ def __init__(self, **kwargs):
3737
self.abort_camera_start = False
3838
self.enable_zoom_gesture = False
3939
self.enable_focus_gesture = False
40+
self.audio = False
4041
self.cg_zoom_level = [1 , 1]
4142
self.window_width = Window.width
4243
if platform == 'ios':
@@ -80,6 +81,7 @@ def on_size(self, instance, size):
8081
def connect_camera(self,
8182
camera_id = '0',
8283
mirrored = True,
84+
audio = False,
8385
sensor_resolution = [],
8486
sensor_rotation = 0,
8587
default_zoom = 1.0,
@@ -90,6 +92,8 @@ def connect_camera(self,
9092
canvas_callback = None,
9193
**kwargs):
9294
self.set_index(camera_id)
95+
if audio == True:
96+
self.audio = True
9397
self.set_resolution(sensor_resolution)
9498
self.set_rotation(sensor_rotation)
9599
self.set_filepath_callback(filepath_callback)
@@ -344,7 +348,7 @@ def clear_texture(self):
344348

345349

346350
def on_tex(self, camera):
347-
if self._camera:
351+
if self._camera and self._camera.texture:
348352
tex = self._camera.texture.get_region(*self.tex_crop)
349353

350354
if self.data_callback:

0 commit comments

Comments
 (0)