#!/bin/sh
#Launch RTP (MPEG-TS) to HLS server
TIMESTAMP=`date +%s`
#Using .bin intead of .ts since .bin gets cached by default by CloudFlare
LOCATION="seg-$TIMESTAMP-%05d.bin"
gst-launch-1.0 \
  udpsrc port=5004 caps="application/x-rtp" ! rtpmp2tdepay ! \
  tsdemux name=demux \
    demux. ! queue ! "video/x-h264" ! h264parse ! muxer. \
    demux. ! queue ! "audio/mpeg,mpegversion=4" ! aacparse ! muxer. \
      mpegtsmux name=muxer ! queue ! \
        hlssink max-files=99999 location="$LOCATION" playlist-length=3 target-duration=5
