the following script will monitor a directory and pass every newly added image to gstreamer which will send it to the video-device (/dev/video0
, but change at will).
call with the path to monitor as the sole argument (e.g. ./pics2v4l2 /tmp/pics
)
#!/bin/sh
DIR=$1
DEVICE=/dev/video0
inotifywait -m "${DIR}" \
| awk '$2== "CLOSE_WRITE,CLOSE" {print $1"/"$3; fflush()}' \
| while read f; do
gst-launch-0.10 uridecodebin uri="file://${f}" \
! ffmpegcolorspace \
! videoscale \
! imagefreeze \
! identity error-after=2 \
! v4l2sink show-preroll-frame=false device=${DEVICE}
done