diff --git a/src/AVDemuxThread.cpp b/src/AVDemuxThread.cpp index 0f4bb77de..61b98e07c 100644 --- a/src/AVDemuxThread.cpp +++ b/src/AVDemuxThread.cpp @@ -128,6 +128,7 @@ void AVDemuxThread::seek(qint64 pos) } if (video_thread) { video_thread->packetQueue()->clear(); + // TODO: the first frame (key frame) will not be decoded correctly if flush() is called. video_thread->packetQueue()->put(Packet()); } //if (subtitle_thread) { diff --git a/src/AVDemuxer.cpp b/src/AVDemuxer.cpp index 958e22bc6..4b900c841 100644 --- a/src/AVDemuxer.cpp +++ b/src/AVDemuxer.cpp @@ -424,7 +424,6 @@ bool AVDemuxer::seek(qint64 pos) return false; } //replay - qDebug("startTime: %lld", startTime()); if (upos <= startTime()) { qDebug("************seek to beginning. started = false"); started_ = false; diff --git a/src/QtAV/VideoFrameExtractor.h b/src/QtAV/VideoFrameExtractor.h index 1e91b416c..642d59189 100644 --- a/src/QtAV/VideoFrameExtractor.h +++ b/src/QtAV/VideoFrameExtractor.h @@ -41,14 +41,18 @@ class Q_AV_EXPORT VideoFrameExtractor : public QObject explicit VideoFrameExtractor(QObject *parent = 0); void setSource(const QString value); QString source() const; + /*! + * \brief setAsync + * Extract video frames in another thread. Default is true. + */ void setAsync(bool value); bool async() const; void setAutoExtract(bool value); bool autoExtract() const; /*! * \brief setPrecision - * if the difference of the next requested position is less than the value, the - * last one is used and not positionChanged() signal to emit. + * if the difference between the next requested position is less than the value, previous + * one is used and no positionChanged() and frameExtracted() signals to emit. * Default is 500ms. */ void setPrecision(int value); @@ -76,8 +80,8 @@ public slots: /*! * \brief extract * If last extracted frame can be use, use it. - * If there is a key frame in [position-precision, position+precision], then the nearest key frame will be extracted. - * Otherwise, the given position frame will be extracted. + * If there is a key frame in [position-precision, position+precision], the nearest key frame + * before position+precision will be extracted. Otherwise, the given position frame will be extracted. */ void extract(); private slots: diff --git a/src/VideoFrameExtractor.cpp b/src/VideoFrameExtractor.cpp index 027472a47..13a121355 100644 --- a/src/VideoFrameExtractor.cpp +++ b/src/VideoFrameExtractor.cpp @@ -133,7 +133,7 @@ class VideoFrameExtractorPrivate : public DPtrPrivate continue; } QVariantHash opt, va; - va["Display"] = "X11"; // to support swscale + va["display"] = "X11"; // to support swscale opt["vaapi"] = va; decoder->setOptions(opt); break; @@ -158,7 +158,7 @@ class VideoFrameExtractorPrivate : public DPtrPrivate if (demuxer.packet()->hasKeyFrame) break; } - decoder->flush(); + // decoder->flush(); // TODO: why key frame can't be decoded? also in VideoThread const qint64 t_key = qint64(demuxer.packet()->pts * 1000.0); //qDebug("delta t = %d, data size: %d", int(value - t_key), demuxer.packet()->data.size()); // must decode key frame @@ -183,7 +183,7 @@ class VideoFrameExtractorPrivate : public DPtrPrivate qreal t0 = qreal(value/1000LL); while (!demuxer.atEnd()) { if (!demuxer.readFrame()) { - qDebug("!!!!!!----read frame error!!!!!!"); + //qDebug("!!!!!!----read frame error!!!!!!"); continue; } if (demuxer.stream() != vstream) {