[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ffmpegthumbs/Applications/18.08] ffmpegthumbnailer: Check whether a frame could be decoded before s
From:       Kai Uwe Broulik <null () kde ! org>
Date:       2018-09-26 8:25:28
Message-ID: E1g558S-00052t-VK () code ! kde ! org
[Download RAW message or body]

Git commit 6fa26cddeff42831a6c6bf885bd8c905a413d3e4 by Kai Uwe Broulik.
Committed on 26/09/2018 at 08:24.
Pushed by broulik into branch 'Applications/18.08'.

Check whether a frame could be decoded before seeking

Otherwise crashes when trying to generate thumbnail for a video file without actual \
video data.

CHANGELOG: Fixed video thumbnailer crashing when trying to decode files without video \
stream

Differential Revision: https://phabricator.kde.org/D15752

M  +3    -2    ffmpegthumbnailer/moviedecoder.cpp
M  +1    -1    ffmpegthumbnailer/moviedecoder.h
M  +3    -1    ffmpegthumbnailer/videothumbnailer.cpp

https://commits.kde.org/ffmpegthumbs/6fa26cddeff42831a6c6bf885bd8c905a413d3e4

diff --git a/ffmpegthumbnailer/moviedecoder.cpp b/ffmpegthumbnailer/moviedecoder.cpp
index b2e7551..6d1a79c 100644
--- a/ffmpegthumbnailer/moviedecoder.cpp
+++ b/ffmpegthumbnailer/moviedecoder.cpp
@@ -227,7 +227,7 @@ void MovieDecoder::seek(int timeInSeconds)
 }
 
 
-void MovieDecoder::decodeVideoFrame()
+bool MovieDecoder::decodeVideoFrame()
 {
     bool frameFinished = false;
 
@@ -237,8 +237,9 @@ void MovieDecoder::decodeVideoFrame()
 
     if (!frameFinished) {
         qDebug() << "decodeVideoFrame() failed: frame not finished";
-        return;
     }
+
+    return frameFinished;
 }
 
 bool MovieDecoder::decodeVideoPacket()
diff --git a/ffmpegthumbnailer/moviedecoder.h b/ffmpegthumbnailer/moviedecoder.h
index 788ce43..060c02e 100644
--- a/ffmpegthumbnailer/moviedecoder.h
+++ b/ffmpegthumbnailer/moviedecoder.h
@@ -39,7 +39,7 @@ public:
 
     QString getCodec();
     void seek(int timeInSeconds);
-    void decodeVideoFrame();
+    bool decodeVideoFrame();
     void getScaledVideoFrame(int scaledSize, bool maintainAspectRatio, VideoFrame& \
videoFrame);  
     int getWidth();
diff --git a/ffmpegthumbnailer/videothumbnailer.cpp \
b/ffmpegthumbnailer/videothumbnailer.cpp index 97218c8..c3fd1c4 100644
--- a/ffmpegthumbnailer/videothumbnailer.cpp
+++ b/ffmpegthumbnailer/videothumbnailer.cpp
@@ -98,7 +98,9 @@ void VideoThumbnailer::generateThumbnail(const QString& videoFile, \
ImageWriter&  {
     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);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic