#!/bin/sh
#Launch UDP-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 ! tsparse ! tsdemux name=demux \
    demux. ! "video/x-h264" ! queue ! h264parse ! muxer. \
    demux. ! "audio/mpeg" ! queue ! aacparse ! muxer. \
      mpegtsmux name=muxer ! queue ! \
        hlssink max-files=99999 location="$LOCATION" playlist-length=3 target-duration=5
