Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IDEA][PI] Screen capture through UVC device #32

Open
hkfuertes opened this issue Dec 30, 2023 · 3 comments
Open

[IDEA][PI] Screen capture through UVC device #32

hkfuertes opened this issue Dec 30, 2023 · 3 comments

Comments

@hkfuertes
Copy link

So I had an idea... what if we could send the screen through the UVC gadget.
I have the PoC working, but I only get 1 FPS... If someone could point me in the right direction I ll be greatly gratefull.

#!/bin/bash

sudo modprobe v4l2loopback video_nr=100 exclusive_caps=1
ffmpeg -f x11grab -i :0.0+0,0 -vcodec mjpeg -pix_fmt yuv420p -f v4l2 /dev/video100 &
sleep 5
uvc-gadget -u /dev/video0 -v /dev/video100 -r 30 &

With this concept, the usb capture card wont be required. The pi could be connected to a pc via usb and get the image through vlc.
Additionally with the ethernet gadget we could also use x2x to control de device...

@kbingham
Copy link

I'm pretty sure I've already seen that this fork has this idea implemented (well, the display side of things)

https://github.com/peterbay/uvc-gadget/blob/master/gadget-framebuffer.sh

@hkfuertes
Copy link
Author

oh! thank you!!
I managed to create the /dev/fb0 by changing values in config.txt, but I need the intermediate step... I guess that I need to startx on some display (I used xvfbor https://techoverflow.net/2019/02/23/how-to-run-x-server-using-xserver-xorg-video-dummy-driver-on-ubuntu/) so that X11/Xserver writes onto the same /dev/fb0 that uvc_gadget is reading from.... But I dont find the solution...

I'll keep digging. Also, Amazon should deliver me today some dummy hdmi plugs... maybe thats the issue....

@hkfuertes
Copy link
Author

hkfuertes commented Dec 31, 2023

So, progress... If I run this, with the option in raspi-config of login to terminal:

echo "dtoverlay=dwc2,dr_mode=otg" | sudo tee -a /boot/firmware/config.txt
echo " modules-load=dwc2,libcomposite" | sudo tee -a /boot/cmdline.txt
git clone https://github.com/peterbay/uvc-gadget
cd uvc-gadget && make
sudo cp ./uvc-gadget /usr/bin/
sudo cp ./gadget-framebuffer.sh /usr/bin/uvcgfb
sudo chmod +x /usr/bin/uvcgfb
sudo cp uvcgfb.service /etc/systemd/system/
sudo systemctl enable uvcgfb.service
sudo apt install xserver-xorg-video-dummy

# Start X on dummy display
sudo startx -- -config dummy-1920x1080.conf
# Manually for now!
sudo uvc-gadget -f /dev/fb0 -u /dev/video0

https://github.com/hkfuertes/pi_uvc_screen_share/blob/main/dummy-1920x1080.conf
https://github.com/hkfuertes/pi_uvc_screen_share/blob/main/uvcgfb.service

I get this:
image

But I only get a black screen If I set it to autologin to desktop...

hahahaha maybe I write to much, but also, maybe its helpfull to someone else... but again if someone know and wants to point me in the right direction, I'll be greatly greateful :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants