Project

General

Profile

Script for automatically making a m3u file of a video directory with ffmpeg pipe in linux.

Added by T Pedersen over 1 year ago

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


Replies (2)

RE: Script for automatically making a m3u file of a video directory with ffmpeg pipe in linux. - Added by T Pedersen over 1 year ago

This is just for the motionrecordings of my cam, have rtsp stream for my live view.

also,

cannot access this cams recordings other than last motion, closed in a subscriptionbased cloud service. using HA to automatically download latest video from the service which is allowed.. would been easier if API where open.

    (1-2/2)