def setsegmentDir(self, manual=False):
        with self.recordlock:
            # Manually triggered recordings should go in a different folder

            my_date = datetime.utcnow()
            date = my_date.replace(
                hour=0, minute=0, second=0, microsecond=0).isoformat() + "+00:00"
            t = my_date.isoformat() + "+00:00"

            d = os.path.join(self.storageDir, self.name, "recordings", date, t)
            os.makedirs(d)
            self.segmentDir = d

            with open(os.path.join(self.segmentDir, "playlist.m3u8"), "w") as f:
                f.write("#EXTM3U\r\n")
                f.write("#EXT-X-START:	TIME-OFFSET=0\r\n")
                f.write("#EXT-X-PLAYLIST-TYPE: VOD\r\n")
                f.write("#EXT-X-VERSION:3\r\n")
                f.write("#EXT-X-ALLOW-CACHE:NO\r\n")
                f.write("#EXT-X-TARGETDURATION:5\r\n")

        # Capture a tiny preview snapshot
        import PIL
        x = PIL.Image.open(io.BytesIO(self.request_data_point("bmp_snapshot")))
        x.thumbnail((320,240))
        x=PIL.ImageOps.autocontrast(x, cutoff=(0.1,0,25))
        with open(os.path.join(self.segmentDir, "thumbnail.jpg"),'wb') as f:
            x.save(f,'jpeg')