diff --git a/ffmpegthumbnailer/moviedecoder.h b/ffmpegthumbnailer/moviedecoder.h --- a/ffmpegthumbnailer/moviedecoder.h +++ b/ffmpegthumbnailer/moviedecoder.h @@ -39,7 +39,7 @@ QString getCodec(); void seek(int timeInSeconds); - void decodeVideoFrame(); + bool decodeVideoFrame(); void getScaledVideoFrame(int scaledSize, bool maintainAspectRatio, VideoFrame& videoFrame); int getWidth(); diff --git a/ffmpegthumbnailer/moviedecoder.cpp b/ffmpegthumbnailer/moviedecoder.cpp --- a/ffmpegthumbnailer/moviedecoder.cpp +++ b/ffmpegthumbnailer/moviedecoder.cpp @@ -227,7 +227,7 @@ } -void MovieDecoder::decodeVideoFrame() +bool MovieDecoder::decodeVideoFrame() { bool frameFinished = false; @@ -237,8 +237,9 @@ if (!frameFinished) { qDebug() << "decodeVideoFrame() failed: frame not finished"; - return; } + + return frameFinished; } bool MovieDecoder::decodeVideoPacket() diff --git a/ffmpegthumbnailer/videothumbnailer.cpp b/ffmpegthumbnailer/videothumbnailer.cpp --- a/ffmpegthumbnailer/videothumbnailer.cpp +++ b/ffmpegthumbnailer/videothumbnailer.cpp @@ -98,7 +98,9 @@ { MovieDecoder movieDecoder(videoFile, NULL); if (movieDecoder.getInitialized()) { - movieDecoder.decodeVideoFrame(); //before seeking, a frame has to be decoded + if (!movieDecoder.decodeVideoFrame()) { //before seeking, a frame has to be decoded + return; + } if ((!m_WorkAroundIssues) || (movieDecoder.getCodec() != QLatin1String("h264"))) { //workaround for bug in older ffmpeg (100% cpu usage when seeking in h264 files) int secondToSeekTo = m_SeekTime.isEmpty() ? movieDecoder.getDuration() * m_SeekPercentage / 100 : timeToSeconds(m_SeekTime);