Created
April 27, 2020 06:37
-
-
Save tayyebi/e9c94ace8f6bdf6050fc7247c85ae160 to your computer and use it in GitHub Desktop.
Camera Virtualization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gst-launch-1.0 -v v4l2src device=/dev/video0 ! \ | |
ffmpegcolorspace ! \ | |
video/x-raw-rgb ! \ | |
ffmpegcolorspace ! \ | |
video/x-raw-yuv,format=\(fourcc\)YUY2 ! \ | |
v4l2sink device=/dev/video2 | |
# Alternative | |
gst-launch-1.0 -v v4l2src device=/dev/video2 ! \ | |
v4l2sink device=/dev/video5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ls /dev | grep video | |
sudo depmod -a | |
# Remove loopback devices | |
sudo modprobe -r v4l2loopback | |
# Enable Loop Back Devices (Method 1) | |
sudo modprobe v4l2loopback video_nr=2 card_label="My Fake Camera" exclusive_caps=1 devices=1 | |
# Enable Loop Back Devices (Alternative Method) | |
sudo insmod /lib/modules/5.3.0-46-generic/extra/v4l2loopback.ko exclusive_caps=1 video_nr=2 card_label="Fake" | |
# Check Device | |
v4l2-ctl --device=/dev/video2 --all | |
# Method 1: Record Desktop | |
# sudo ffmpeg -f x11grab -r 25 -s 416x768 -i :0.0+0,0 -vcodec rawvideo -pix_fmt yuv420p -threads 0 -f v4l2 /dev/video2 | |
# Method 2: Record RTMP Stream | |
ffmpeg -f flv -listen 1 -i rtmp://localhost:1935/live/app -f v4l2 /dev/video2 | |
# Check the output | |
ffplay /dev/video2 | |
udevadm info --name=/dev/video2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Attach camera to guest machine | |
VBoxManage list webcams | |
VBoxManage controlvm "android" webcam attach /dev/video2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment