0

我正在编写一个程序,它将从 IP 摄像机获取视频流并显示其视频。

我请求 MJPEG 流、解析数据并在 WPF 控件上逐帧显示以制作视频。

我将我的程序与其他程序进行了比较,我发现我的程序显示的视频不如其他程序流畅,尽管帧率显示相同。

我通过顺序更新控件的图像在 WPF 控件上显示视频。

谁能告诉我为什么我的程序不流畅?以及如何改进它。

更新:

@LearnedfromMistake:有 2 个线程。线程#1 将请求、解析来自相机流的数据并将帧追加到队列中。线程#2 将从队列中获取帧并显示它。

这是我的伪代码。

Thread #1    
{    
   while(true)    
   {    
      JpegFrame = ReadAFrameFromStream();    
      QUEUE.Append(JpegFrame);
   }    
}

Thread #2    
{    
   while(true)    
   {    
      JpegFrame = QUEUE.GetFrame();    
      WPFControl.UpdateImage(JpegFrame); //Making video here
   }    
}
4

1 回答 1

1
  • while video frames are supposedly taken at regular time intervals, they might be encoded with different delays, transmission and buffering delays/lanetcies apply and eventually your receive rate is not regular, you need to compensate for this to restore smooth feed
  • WPF control repaint overhead is greater compared to presentation through specialized multimedia APIs

The best would be facilitate multimedia streaming APIs where images are decoded into YUV frames and presented accurately according to attached time stamps.

于 2013-01-26T15:19:15.993 回答