精通
英语
和
开源
,
擅长
开发
与
培训
,
胸怀四海
第一信赖
My name is Fabio, and i'm developing a c# app, where i need to stream mjpeg video from c# to a mobile device. I am having serious problems to do it but your snippet seems pretty promissor. I've been trying to stream sets of images, and that works fine, but i really cant change it to stream video frames because the IEnumerable don't accept it.
我的名字是法比奥,我开发一个c#应用程序,我需要从c#串流mjpeg视频到移动设备。 我有严重的问题,但你的片段代码似乎让我很有希望。 我一直试图串流一组图像,这没问题,但我真的不能串流视频帧,因为IEnumerable不接受它。
My question is, do you already change your functions to allow video streaming? If you didn't, how do o plan to do it? 我的问题是,你已经改变你的函数允许视频串流吗? 如果你没有,啊,打算怎么做?
Thanks for your help, and for your excellent work 谢谢你的帮助和你的出色工作
Hi, you may create a class to read video frames and output IEnumerable<Image> to the image streaming server. I appended a sample class where you can call AssignNewFrame function to update the image to current video frame. There is also an example of how to use the class ImageStreamSource with the mjpeg streaming server.
你好,你可以创建一个类来读取视频帧和输出到IEnumerable<Image>图像到流媒体服务器。 我附加一个示例类,您可以调用AssignNewFrame函数来更新当前视频帧图像。 还有一个例子,如何使用类ImageStreamSource mjpeg流媒体服务
public class ImageStreamSource : IEnumerable
{
bool IsActive = true;
Image latestImage = null;
ManualResetEvent newFrameMre = new ManualResetEvent(true);
public ImageStreamSource()
{
}
public void AssignNewFrame(Image item)
{
latestImage = item;
newFrameMre.Set();
}
// IEnumerable Member
public IEnumerator GetEnumerator()
{
yield break;
}
public IEnumerable<Image> GetImageEnumerator()
{
while (IsActive)
{
newFrameMre.WaitOne();
yield return latestImage;
}
yield break;
}
public void Stop()
{
IsActive = false;
}
}
//Initialization
ImageStreamSource imageStreamingSource = new ImageStreamSource();
ImageStreamingServer imageStreamingServer = new ImageStreamingServer(imageStreamingSource.GetImageEnumerator()); //Usage
Bitmap frame = new Bitmap("some video frame");
imageStreamingSource.AssignNewFrame(frame);
Hi Joshua,嗨,约书亚,
Thanks a lot for your help. In the mean time i kept working with your framework and had already done something like what you did, but your code is better Now it works almost fine, but once i have much to process in each frame after a few seconds the frames start arriving with delay to the mobile. It is possible to discard the old frames in memory and jump to the most recent ones?
非常感谢你的帮助。 同时我一直使用你的框架已经完成,但是您的代码更好 现在工作很好,但是一旦几秒钟后,我有许多帧处理前事务多时,在每一帧的帧到达移动端时有移动。 可以丢弃最近的旧帧,跳转到最新帧吗?
Thanks again for your help 再次感谢你的帮助