From ff08acc556d8e40d501522efcbecac68bb8973c6 Mon Sep 17 00:00:00 2001 From: Mitchell Stokes Date: Fri, 9 May 2014 13:51:57 -0700 Subject: BGE VideoTexture: Fix for loading PNG (and possibly other) files. --- source/gameengine/VideoTexture/VideoFFmpeg.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp index 44017f37d29..179f1ced03b 100644 --- a/source/gameengine/VideoTexture/VideoFFmpeg.cpp +++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp @@ -1005,9 +1005,20 @@ AVFrame *VideoFFmpeg::grabFrame(long position) { if (packet.stream_index == m_videoStream) { - avcodec_decode_video2(m_codecCtx, - m_frame, &frameFinished, + if (m_isImage) + { + // If we're an image, we're probably not going to be here often, + // so we don't want to deal with delayed frames from threading. + // There might be a better way to handle this, but I'll leave that + // for people more knowledgeable with ffmpeg than myself. We don't + // need threading for a single image anyways. + m_codecCtx->thread_count = 1; + } + + avcodec_decode_video2(m_codecCtx, + m_frame, &frameFinished, &packet); + // remember dts to compute exact frame number dts = packet.dts; if (frameFinished && !posFound) -- cgit v1.2.3