Is there any way to force raspivid or any other tool to display preview from camera (on hdmi display) side by side cloned, so it could be used in VR glasses?

1 Answer 1


I've never seen this done myself, but there was some discussion a while back on the RPi camera forum about either trying to use the MMAL video splitter component with the camera's preview output, or attaching a renderer to both the video and preview ports.

Quick high level overview of both raspivid and picamera:

  • both use the MMAL API
  • the MMAL API's camera component provides three virtual "ports": still, video, and preview (still is for doing still captures and involves lots of extra processing when it's used so we'll ignore it here)
  • when raspivid or picamera initialize they immediately connect something to the preview port; in the case of picamera this is always a null sink just to keep the preview port active; in the case of raspivid it's a null sink if the preview is disabled or a preview renderer otherwise (the null sink is necessary to work around issues that occur when the preview port is ignored)
  • here's where things start to get different: picamera then sticks a video splitter component on the video port to support things like recording at multiple resolutions, recording to H.264 while analyzing YUV, etc. etc. while raspivid sticks an H264 encoder on the video port and gets recording

So you could take apart raspivid and try initializing a second preview renderer then sticking it on the video port, or you could have a look at picamera's splitter usage and try sticking one of those on the preview port (then a second preview renderer on its outputs). Resizing a preview renderer to only cover part of the screen is pretty trivial (both raspivid and picamera provide this capability).

I'm not sure if either of these will work or if one is better than the other. My understanding is that MMAL is a pretty high level abstraction of what goes on in the firmware so there's probably all sorts of stuff going on under the covers that will make a difference in terms of performance or capability but it's definitely where I'd start.

  • Huh ... I'd forgotten about this answer. I actually wrote an implementation of this on here a couple of years later: raspberrypi.stackexchange.com/a/60126/12729 (the mmalobj layer that the later answer uses didn't exist when I wrote this first answer)
    – Dave Jones
    Jan 20, 2018 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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