RetroPie Screen Mirroring / Streaming / Casting
There are a few different methods to mirror/cast/record video from the pi to an external display. Just thought I'd consolidate some thoughts.
One method is a VNC server which doesn't really work with RetroPie as it doesn't use an X server.
An alternate would be to use Dispmanx VNC
In theory it should work without X.
Another option for retropie might be the raspidisp driver as part of UV4L (webrtc)
I'm expecting lag and barely passable functionality but thought I would just try some things out as a proof of concept and will update the post accordingly as I make progress. Would be interested in any other results if anyone else is trying the same thing.
zerojay last edited by
External video capture card with HDMI passthrough.
@zerojay I'm mostly just thinking of software solutions. not solutions that work!
sudo apt-get install libvncserver-dev
Clone github repo:
git clone https://github.com/hanzelpeter/dispmanx_vnc.git
Modify makefile for stretch:
chmod +x makeit
then you need a vnc client, krdc seemed to work fine on mine and i just connected with the IP at port 5900 eg
runs at a cool 15 FPS! also only worked when I was using kodi, just shows black screen for others so, might be a bit subjective
curl http://www.linux-projects.org/listing/uv4l_repo/lpkey.asc | sudo apt-key add -
deb http://www.linux-projects.org/listing/uv4l_repo/raspbian/stretch stretch main
sudo apt-get update sudo apt-get install uv4l uv4l-server uv4l-webrtc uv4l-raspidisp uv4l-raspidisp-extras
Then I used this to start the server
uv4l --auto-video_nr --driver raspidisp --server-option '--enable-webrtc=yes'
There are obviously some tweaks that can be made and lots of the arguments are detailed in the man pages.
then I accessed it from my web browser at
http://192.168.1.63:9080/stream/webrtc/then just clicked call at the bottom and viola. The audio doesn't work by default and they mentioned it would need a loopback of sorts with alsa, I delved into that in the past and failed miserably but it funtions so thats cool.
madmodder123 last edited by
I know this isn't exactly streaming/mirroring/casting, but this utility is great for grabbing screenshots directly from the Pi's framebuffer: https://github.com/AndrewFromMelbourne/raspi2png
@madmodder123 I've used it and I wasn't particularly enamoured with the quality of the screenshots though it's definitely a step up from a screenshot with a phone. Also possible it could be fixed with some config tweaks but I didn't look into it too much.
First and foremost, many thanks for this, as I'm toying with the idea of streaming my cabinet's picture to my video projector (just mentioned for others here, as you already know it from the other thread we talked in).
Alas, both options have issues on Retropie 4.3 based on Debian Jessie which I'm still using on my cabinet, because I didn't want to change a running system without reasons. I may have a reason now, but it keeps me from testing it right now, and I'm reluctant to upgrade to 4.4 because of its issues with the order of joysticks.
DISPMANX: On 4.3, I get only around 4-5 fps with krdc 4.13.0 on Kubuntu 14.04 (yeah, I also never changed that running system, but I plan to upgrade to 18.04 when its first point release 18.04.1 comes out in summer). Maybe because of lGLESv2 and lEGL on Jessie? As suspected, with lbrcmGLESv2 and lbrcmEGL there is no picture on the client, but I wanted to try it to be sure.
UV4L raspidisp: Can't install it because an unmet dependency for libssl1.0.2.
$ sudo apt install uv4l uv4l-server uv4l-webrtc uv4l-raspidisp uv4l-raspidisp-extras Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: uv4l-server : Depends: libssl1.0.2 but it is not installable E: Unable to correct problems, you have held broken packages.
Do you have any ideas for this aside from installing Retropie 4.4?
Do you have any ideas for this aside from installing Retropie 4.4?
Sorry my posts we're implied I was working off stretch.
No time like the present to upgrade to the supported OS. SD cards are relatively cheap, I have at least 8 for testing.
@herb_fargus Yeah, I think you're right. Off to the vendor! (in the coming week)
6Alli last edited by
This post is deleted!
@herb_fargus Hi, I finally got to install Retropie 4.4, but I ran into a problem with UV4L. I followed your instructions by the letter. Starting the server got me this:
$ uv4l --auto-video_nr --driver raspidisp --server-option '--enable-webrtc=yes' <notice> [core] Trying to loading driver 'raspidisp' from built-in drivers... <notice> [core] Loading driver 'raspidisp' from external plug-in's... <notice> [driver] RaspiDisp Video4Linux2 Driver built Jan 31 2017 <notice> [core] Device detected! <notice> [core] Registering device node /dev/video0
The server is running on pids 3215 and 3065 according to
pidof uv4l. But when I try to connect by
http://ip.of.my.raspi:9080/stream/webrtc/, the browser says:
Page Not Found or Access Denied
The PC I'm trying to connect from runs Kubuntu Linux 14.04. The error occurs in Firefox 59.0.2 as well as Chromium 65.0.3325.181.
What could be wrong?
@clyde hrm. I don't remember mine saying /dev/video0, it was dev something else I forget. Did you try it with sudo /rebooting the pi?
@herb_fargus Rebooting didn't change the error, but uv4l only has one pid now.
I also have an issue with dispmanx vnc. It works, but although it shows approx. 13 fps on the Pi, krdc on my pc only gets appros 2 fps with high quality and 3 fps with medium quality. Low quality doesn't show a picture at all.
edit: The poor vnc performance might be because my Retropi runs on 1600x1200 …
Update: I can connect to the server's menu via http://ip.of.my.raspi:8080. There, "Server Info" says:
Streaming Server Informations and Statistics
- basic HTTP/HTTPS authentication: disabled
- underlying video device node: /dev/video0
- current connections: 1, queued: 0, total handled: 15
- max. simultaneous streams allowed: 3, max. threads: 5
- raw HTTP/HTTPS video streams in MJPEG, JPEG (continuous stills) and H264 formats - if supported - are available under the /stream/video.mjpeg, /stream/video.jpeg, and /stream/video.h264 URL paths respectively
But none of the listed url paths work. They give the error
Okay, I got it: I just had to use your URL with my server's port 8080. I don't know why your server has a different port, since I only followed your instructions. But it works now with an acceptable framerate, albeit not as high as the original.
So, thanks very much for this solution! Do you have any tipps for optimizing the frame rate? My video projector's resolution is 1280x720, I'd like to render the stream in this resolution. If you happen to know the options to do that, I'd be thankful. Otherwise, I'll try to read them up.
@clyde glad you got it figured out. you probably know as much about it as I do at this point. Uv4l has manpages with different settings that could probably be tweaked to improve performance.
If you/I were really ambitious we could develop a custom web app plug-in specific to streaming for retropie (uv4l had an example of an app for face tracking)
@herb_fargus One feature I'd like would be a direct stream without any web interface that could be viewed by a network-compatible media player like vlc. If that's possible already, I didn't figure it out although I read many uv4l docs and tutorials.
Do you know (or suspect) which video format the webrtc plugin streams to /dev/video0 in? I tried to grab that device with cvlc and stream it to another cvlc running on my pc with Kubuntu like described in this tutorial, but cvlc on the Pi didn't recognize the format coming from /dev/video0 (even calling it "garbage" at one point).
As for developing a custom plug-in, I am open for that in principle, but I have no programming expertise at all, apart from some very basic bash scripting (example).
Do you know (or suspect) which video format the webrtc plugin streams to /dev/video0 in?
Something like this - https://www.linux-projects.org/uv4l/tutorials/rtsp-server/ ?
@mitu Sorry for the late answer, I somehow missed your reply. 😮
Your link points to a tutorial for the raspicam driver. It has an
--encodingoption the raspidisp driver is missing, unfortunately.