Initial commit
This commit is contained in:
commit
a080b68a79
49
stream.sh
Executable file
49
stream.sh
Executable file
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
if ! command -v inotifywait >/dev/null 2>&1; then
|
||||||
|
echo "Please install inotify_utils"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
declare -A STREAMS
|
||||||
|
|
||||||
|
|
||||||
|
streaming() {
|
||||||
|
while true; do
|
||||||
|
echo "Streaming $1"
|
||||||
|
#echo ffmpeg -loglevel -8 -f v4l2 -framerate 30 -input_format mjpeg -i "/dev/$1" -f libndi_newtek -y "$1"
|
||||||
|
~/ndi/ffmpeg/ffmpeg -f v4l2 -framerate 30 -input_format mjpeg -i "/dev/$1" -pix_fmt uyvy422 -f libndi_newtek -y "$1.mov"
|
||||||
|
echo "Failed $1; Restarting"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_initial_devices() {
|
||||||
|
for file in /dev/video*; do
|
||||||
|
echo "Found ${file##*/}"
|
||||||
|
(streaming "${file##*/}") &
|
||||||
|
STREAMS[$file]=$!
|
||||||
|
echo "${file##*/} PID ${STREAMS[$file]}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
listen_for_new_devices() {
|
||||||
|
inotifywait -m /dev --format "%f" -e create |
|
||||||
|
while read -r file; do
|
||||||
|
echo "Found $file"
|
||||||
|
if [[ -v "STREAMS[$file]" && "$file" =~ video\d+$ ]]; then
|
||||||
|
(streaming "$file") &
|
||||||
|
STREAMS[$file]=$!
|
||||||
|
echo "$file PID ${STREAMS[$file]}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
check_initial_devices
|
||||||
|
listen_for_new_devices
|
||||||
12
testvideo.sh
Executable file
12
testvideo.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
~/ndi/ffmpeg/ffmpeg \
|
||||||
|
-s 1280x720 \
|
||||||
|
-framerate '30' \
|
||||||
|
-f rawvideo \
|
||||||
|
-pix_fmt rgb24 \
|
||||||
|
-i /dev/zero \
|
||||||
|
-vf "drawbox=enable='mod(n,2)':w=iw:h=ih:c=green:t=ih*0.02,drawbox=enable='not(mod(n,2))':w=iw:h=ih:c=blue:t=ih*0.02,drawtext=text='':timecode='00\:00\:00\:00':rate=30000/1000:x=(w-tw)/2:y=h-(h-th)/2:fontcolor=white:fontsize=90:box=0" \
|
||||||
|
-pix_fmt uyvy422 \
|
||||||
|
-f libndi_newtek \
|
||||||
|
-y video1
|
||||||
Loading…
Reference in a new issue