[Libav-user] FFmpeg lib + UDP + Qt issues

isyiwang isaac.wang at visorcorp.com
Wed Sep 14 19:20:56 CEST 2011


Hello, 
First of all, thank you to this amazing community of developers!  I have 
received a tremendous amount of help both directly and indirectly thanks 
to you all. 

I am in need of some help regarding reading encoded video udp packets 
and decoding them into a Qt display.  I have managed to read the video 
packets and display them in Qt but video playback 'stutters'.  Checking 
the FPS of frames transmitted via the FFMpeg library to Qt, I get ~30 
frames per second, so I'm led to believe that FFMpeg itself is sending 
me the same frames multiple times a second.  All of the relevant code chunks
are here: http://pastebin.com/9gaYDaYD. Here are the steps I took: 


     1. Broadcast an H.264 encoded video stream via VLC to 
udp:/238.38.38.38:1234 

     2. Use FFMpeg lib to decode the stream. -- I have a periodic timer that
requests the latest frame from FFMpeg. If I set the timer to a low rate (20
FPS), I get the video played back but at a slow rate.  If I set the timer to
a high rate (60 FPS), I get the frames as soon as they are ready, but the
video stutters.  I figured that I should request the frames back as fast as
possible.  Note that I have placed the demuxing/decoding of the UDP stream
on a separate thread from the displaying of the frames as per avplay.  Any
insight on how to avoid the stuttering is appreciated. 

     3. Send the QImage back to Qt to be displayed -- I have tested the 
frames received by my Qt callback per second and can confirm that I am 
receiving ~ 30 FPS which leads me to believe the stuttering is caused by 
FFMpeg lib. 

     4. I also wrote an interrupting callback to be called by FFMpeg if 
any of the blocking functions (i.e. av_read_frame) took too long (see
Pastebin link) 

Although I sometimes do receive the "Video Timed Out!" call, the 
av_read_frame function still blocks... 

Any help would be greatly appreciated!

--
View this message in context: http://libav-users.943685.n4.nabble.com/FFmpeg-lib-UDP-Qt-issues-tp3813581p3813581.html
Sent from the libav-users mailing list archive at Nabble.com.


More information about the Libav-user mailing list