Video Capture in iOS and MacOS

I’m trying to add video streaming to an audio app and have run across some problems with the iOS build. I’m using CameraDevice to capture the video with a listener to queue and encode frames. The project works fine in MacOS, but as soon as I try it on iOS the listener is called exactly once and never again. I also hear the simulated shutter sound on the device, which would suggest that it’s just taking a still picture. The preview component works fine. This is the relevant code:

void VideoCapture::openCameraAsync( int deviceNumber )
    SafePointer<VideoCapture> This (this);

    CameraDevice::openDeviceAsync ( deviceNumber,
                               [This] (CameraDevice* device, const String& error) mutable
                                    This->cameraDeviceOpenResult (device, error);

void VideoCapture::cameraDeviceOpenResult (CameraDevice* device, const String& error)
    // If camera opening worked, create a preview component for it..
   cameraDevice.reset (device);

   if ( cameraDevice.get() != nullptr)
       cameraDevice->addListener( this );
       cameraPreviewComp.reset (cameraDevice->createViewerComponent());
       addAndMakeVisible (cameraPreviewComp.get());
       resized ();
       DBG ( "Camera opened OK" );
       AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon, "Camera open failed",
                                         "Camera open failed, reason: " + error);
       delete this;
void VideoCapture::imageReceived (const Image &image)
    if ( image.getWidth() == 0 ) return;
    Image *imageCopy = new Image ( image.rescaled ( image.getWidth()/2, image.getHeight()/2) );
    encoderQueue->pushItem( imageCopy );

Any ideas?

Hi - anybody have any idea about this?

Thanks, it looks like that behaviour was buggy. I’ve pushed a change which should provide equivalent behaviour on iOS and macOS:

Hi. I tried this out (same code as above) and it’s not quite the same behaviour as in MacOS. What happens is it takes a continual stream of photos (about 2 per second) and you can hear the simulated shutter sound with each photo.

Just a quick update on this if anyone is watching - what I wanted was to capture video and stream H264, which isn’t what the module is intended for. Turns out that with a little hacking of the Juce code for recording video and a wrapper on the Video Toolbox, this works fine (although Video Toolbox is really obscure if you don’t know H264). Next stop Windows

1 Like