Click here to Skip to main content
15,879,095 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello!
I have been working on the solution to develop video streaming services on server side using C#. In my case I need to implement videostream from file (or other stream, not any devices) to local network via Ethernet for clients. I try use AForge.NET Framework and AForge.FFmpeg.dll namespace. I convert my images to mp4 video.

My code for converting images to video file

C#
using (var vFWriter = new VideoFileWriter())
        {
            // Create file
            vFWriter.Open("VideoMaker.avi", width, height, framRate, VideoCodec.MPEG4);

            foreach (var imageEntity in lstImg)
            {
                //var bmp = ToBitmap(ImageToByteArray(lstImg));
                var bmp = new Bitmap(imageEntity);
                vFWriter.WriteVideoFrame(bmp);
            }

            Debug.WriteLine($"Images quantity: {lstImg.Count}");
            vFWriter.Close();
        }


So I think I need to use VideoFileReader class to read my video.
C#
using (var fileReader = new VideoFileReader())
      {
          fileReader.Open("VideoMaker.avi");

          Debug.WriteLine("width:  " + fileReader.Width);
          Debug.WriteLine("height: " + fileReader.Height);
          Debug.WriteLine("fps:    " + fileReader.FrameRate);
          Debug.WriteLine("codec:  " + fileReader.CodecName);
       }


AForge.NET Framework does not provide any API for streaming video to network.
I think about FFmpeg and Gst-sharp(gstreamer), but I can't find any solution to create stream.
Any suggestions?

What I have tried:

AForge.NET
C#
using (var fileReader = new VideoFileReader())
      {
          fileReader.Open("VideoMaker.avi");

          Debug.WriteLine("width:  " + fileReader.Width);
          Debug.WriteLine("height: " + fileReader.Height);
          Debug.WriteLine("fps:    " + fileReader.FrameRate);
          Debug.WriteLine("codec:  " + fileReader.CodecName);
       }
Posted
Updated 20-Jul-18 9:46am

1 solution

 
Share this answer
 
Comments
Ledrunning 24-Jul-18 9:28am    
Hello! You saved a lot of time for me. But I have next question. Does MS Expression support converting images to video?
Ledrunning 25-Jul-18 9:36am    
How can I play stream video from Microsoft expression and how generate broadcast link?
[no name] 25-Jul-18 15:58pm    
Did you install it? It has all the samples you need; plus there's an SDK.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900