If I have a running process using the camera (recording, streaming, motion detection or whatever), is it possible to adjust the brightens from a 2nd SSH session or from a different deamon process running in the background?

I have tried stuff like raspivid -br 90 but it fails with:

mmal: mmal_vc_component_enable: failed to enable component: ENOSPC

This was done while the camera was streaming video, which just kept working and was not interrupted, but it obviously had no effect.

Is there any othe commandline or scriptable way to do this or does the original working process have exclusive rights on anything camera related?


Bad news first: only one process can access the camera at a given time, and raspivid is (for the most part) non-interactive, so I'm afraid you won't be able to use a second raspivid process to control the first one (the second process will attempt to open the camera and find it already locked by the first process).

Now the good news: it's certainly possible to manipulate the brightness and contrast of the camera (and many other things!) while it's running (and recording), so it shouldn't be terribly difficult to create a script which allows such manipulation from the initial SSH session.

Here's a little script which uses curses (a venerable console interface library) to provide a simple keystroke based interface to the camera. It allows adjusting brightness, contrast, saturation while the camera is running, and permits recording to be started and stopped (and being text based obviously runs happily in an SSH session):

#!/usr/bin/env python

import sys
import picamera
import curses

def main(window):
    with picamera.PiCamera() as camera:
        camera.resolution = (1280, 720)
        camera.framerate = 24
        while True:
            window.addstr(0, 0, 'Press Q to quit')
            window.addstr(2, 0, 'Brightness: %5d (W/S)' % camera.brightness)
            window.addstr(3, 0, 'Contrast:   %5d (E/D)' % camera.contrast)
            window.addstr(4, 0, 'Saturation: %5d (R/F)' % camera.saturation)
            window.addstr(5, 0, 'Recording:  %5s (Space)' % camera.recording)
            c = sys.stdin.read(1).lower()
            if c == 'q':
            elif c == 'w':
                camera.brightness = min(camera.brightness + 1, 100)
            elif c == 's':
                camera.brightness = max(camera.brightness - 1, 0)
            elif c == 'e':
                camera.contrast = min(camera.contrast + 1, 100)
            elif c == 'd':
                camera.contrast = max(camera.contrast - 1, -100)
            elif c == 'r':
                camera.saturation = min(camera.saturation + 1, 100)
            elif c == 'f':
                camera.saturation = max(camera.saturation - 1, -100)
            elif c == ' ':
                if camera.recording:


Obviously you could use some other interface (network or even GPIO based) to talk to the process while it's running, but hopefully that demonstrates the principle!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.