I am trying to create a preview of my rtmp stream. But RTMP playback occupies the bandwidth as source, I want to do mjpeg streaming using ffmpeg and c#. Is it possible to do?
I am trying to create a webpage where users can monitor the stream. For this I dont need to use RTMP url to watch as it needs more and more bandwidth.
So, my idea is to capture images and show them in sequence rate controlled at 1 frame per second. In this way users can monitor.
I have tried various methods like using mjpeg
ffmpeg.exe -i renditiontest.mp4 -c:v mjpeg -q:v 31 -an sample.avi
Now, output file is getting generated. But, it is occupying harddisk.
So, next way is to create images overwriting previous images
ffmpeg.exe -y -i renditiontest.mp4 -f image2 -updatefirst 1 sample2.jpg
Now, I tried creating a stream which will continously read the image and write it as response in C#.
using (WebClient webClient = new WebClient())
{
string url = "http://localhost/probe_VOD/mjpg/sample2.jpg";
var memoryStream = new MemoryStream(webClient.DownloadData(url));
response.Headers.AcceptRanges.Add("bytes");
response.StatusCode = HttpStatusCode.OK;
response.Content = new StreamContent(memoryStream);
//response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("render");
//response.Content.Headers.ContentDisposition.FileName = "sample.jpg";
response.Content.Headers.ContentType = new MediaTypeHeaderValue("multipart/x-mixed-replace; boundary=myboundary");
response.Content.Headers.ContentLength = memoryStream.Length;
}
return response;
Please let me know how do I acheive this.