Skip to content

Instantly share code, notes, and snippets.

@gustavohenrique
Last active April 27, 2020 10:43
Show Gist options
  • Select an option

  • Save gustavohenrique/6a8ccdc3d1ba1f2f8f9aeb8944d834bd to your computer and use it in GitHub Desktop.

Select an option

Save gustavohenrique/6a8ccdc3d1ba1f2f8f9aeb8944d834bd to your computer and use it in GitHub Desktop.
Share a webcam over network/wifi almost latency free using v4l2loopback and ffmpeg
#!/bin/bash
set -euo pipefail
SENDER=192.168.178.25
RECEIVER=192.168.178.59
PORT=8445
#on receiver
nc -l $PORT | ffmpeg -f rawvideo -pix_fmt yuyv422 -s:v 640x480 -i - -f v4l2 /dev/video0 2> /dev/null &
#on sender
ssh $SENDER "v4l2-ctl --stream-mmap --stream-to=- 2>/dev/null | nc $RECEIVER $PORT"
#use ssh for more security
#ssh $SENDER "v4l2-ctl --stream-mmap --stream-count=-1 --stream-to=-"| ffmpeg -f rawvideo -pix_fmt yuyv422 -s:v 640x480 -i - -map 0:v -f v4l2 /dev/video1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment