Can I capture an HLS stream while playing it?

Is it possible to play an HLS stream while simultaneously capturing the stream to a video file that can be played back later?


I'm working with a customer that is building a security camera, and they want their users to be able to record as well as view the video stream from their cameras.


The customer is open to creating whatever kind of video stream I tell them will work best, so I'm not limited to working with an existing device or firmware. I know that HLS is the easiest kind of stream to play, but I don't know anything about capturing it to a file.


I did a project last year that involved recording video from the camera while simultaneously displaying it. For this project I used AVCaptureSession with AVCaptureDevice, so I understand how that all works. If I could create an AVCaptureDevice out of the HLS video stream, I know how to do the rest... is such a thing possible?


Thanks,

Frank