<div dir="ltr"><div>Hi all,</div><div><br></div><div>I have a multithreaded C# application on windows 7 that displays multiple video streams from a server.</div><div>The way it works is that each stream is connected to the server to get the frames, and a dedicated thread (one per stream) is decoding the frame using ffmpeg and then rendering.</div>
<div><br></div><div>There is a wrapper class that calls ffmpeg that was written in managed C++/CLI (vs 2010).</div><div>The frame memory is allocated in unmanaged code using Marshal.AllocHGlobal().</div><div><br></div><div>
The problem is that when having multiple threads (above 8) calling avcodec_decode_video2  returns zero in gotPicture return parameter.</div><div>As a result, there's no frame to display. </div><div><br></div><div>I enabled debug logging and noticed that this happens only in the last 4 threads that were added.</div>
<div>The error log says: "no picture ooo" (Out Of Order debug log in h264.c.</div><div><br></div><div>I verified that the frames are coming from the server at the right order by checking the timestamp on each one.</div>
<div><br></div><div>I tried to add a lock around the call to avcodec_decode_video2   but that didn't change anything.<br></div><div><br></div><div>Is this a threading issue with avcodec_decode_video2 or h264?</div><div>
any idea what am I doing wrong or how can this be fixed?</div><div><br></div><div>Running on Windows 7 64 bit.</div><div>Using zeranoe ffmpeg build from last week.</div><div>Mainly using H264 decoding but I also saw this error when using MPEG4.</div>
<div><br></div><div>Many thank!</div><div><br></div><div>Ofer Bar</div><div><br></div><div><br></div>
</div>