How to display video smoothly?

痞子三分冷 提交于 2019-12-13 02:45:28

问题


I'm writing a program that will get video stream from IP Camera and display its video.

I request MJPEG stream, parse data and display frame by frame on WPF control for making video.

I have compared my program with the other programs, and I saw that my program displayed video less smooth than others although the FRAME RATE DISPLAY is same.

I displayed video on a WPF control by updating control's image sequentially.

Someone can tell me why my program is not smooth? and how to improve it.

UPDATE:

@LearnedfromMistake: There are 2 threads. Thread #1 will request, parse data from Camera stream and Append frames into Queue. Thread #2 will get frame from Queue and display it.

Here is my Pseudo code.

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

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

回答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.



来源:https://stackoverflow.com/questions/14538073/how-to-display-video-smoothly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!