Hi,
Just wanted to share this script for integrating mp4 videos from a security cam into tvheadend.
I have an directory that autopopulate downloaded mp4 files from my security cam if any motions is detected.
with cronjobs and this script I can almost instantly view my camera feed motionrecordings on any TV.
This script is intended for mp4 files, but can be adjusted for other formats and hw.
I`m currently using a rpi4 with rasbian buster.
rawurlencode() {
local string="${1}"
local strlen=${#string}
local encoded=""
local pos c o
for (( pos=0 ; pos<strlen ; pos++ )); do
c=${string:$pos:1}
case "$c" in
[-_.~a-zA-Z0-9] ) o="${c}" ;;
* ) printf -v o '%%%02x' "'$c"
esac
encoded+="${o}"
done
echo "${encoded}"
}
rm -rf p.m3u
for f in *.mp4; do echo "#EXTINF:-1 group-title=DoorCam,SR:$f
pipe:///usr/bin/ffmpeg -loglevel fatal -c:v h264_mmal -i /usr/share/hassio/homeassistant/downloads/"$(rawurlencode $f) -b:v 10000k -acodec copy -vcodec h264_omx -bsf:v h264_mp4toannexb,dump_extra -f mpegts pipe:1
done
sed -i '1s/^/#EXTM3U\n/' securitycam.m3u
rm -rf l.m3u
for f in *.mp4; do echo "#EXTINF:-1 group-title=DoorCam,SR:$f
pipe:///usr/bin/ffmpeg -loglevel fatal -c:v h264_mmal -i /usr/share/hassio/homeassistant/downloads/$f" -b:v 10000k -acodec copy -vcodec h264_omx -bsf:v h264_mp4toannexb,dump_extra -f mpegts pipe:1
done
sed -i '1s/^/#EXTM3U\n/' securitycamb.m3u