Prologue:
I have a hikvision ipcamera that streams raw h264 from a rtsp:// url, I need to play this live feed in the browser.
I managed to get a basic RTSP->ffmpeg-> (faststart) mp4 pipeline working and I can play the video when saved to a file.
I don't understand how to make my controller action "streamable".
I've tried various approaches like writing to Response.Body, Transfer-Encoding: chunked but nothing seems to work. Here is the basic code:
public IActionResult Play5(){
var ms = new MemoryStream();
var muxer = new RTSPToMp4(ms);
Task.Run(() => muxer.Stream());
return new FileStreamResult(ms, "video/mp4");
}
The memory stream contains the live feed but the response is empty here is the request\response from chrome:
Request
method: GET
:path: /api/stream/play5
:scheme: https
accept: */*
accept-encoding: identity;q=1, *;q=0
accept-language: it-IT,it;q=0.9,en-US;q=0.8,en;q=0.7
cache-control: no-cache
pragma: no-cache
range: bytes=0-
referer: https://localhost:5001/Stream
sec-fetch-dest: video
sec-fetch-mode: no-cors
sec-fetch-site: same-origin
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36
Response
content-length: 0
content-type: video/mp4
date: Thu, 08 Oct 2020 14:31:06 GMT
server: Kestrel
status: 200
Am I missing something?