Skip to content

Commit

Permalink
note for async frame extract
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 11, 2015
1 parent e7eab22 commit 568fe86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/QtAV/VideoFrameExtractor.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014 Wang Bin <[email protected]>
Copyright (C) 2014-2015 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -44,6 +44,8 @@ class Q_AV_EXPORT VideoFrameExtractor : public QObject
/*!
* \brief setAsync
* Extract video frames in another thread. Default is true.
* In async mode, if current extraction is not finished, new
* setPosition() will be ignored.
*/
void setAsync(bool value);
bool async() const;
Expand Down
11 changes: 6 additions & 5 deletions tests/extract/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ class VideoFrameObserver : public QObject

public Q_SLOTS:
void onVideoFrameExtracted(const QtAV::VideoFrame& frame) {
//VideoFrameExtractor *e = qobject_cast<VideoFrameExtractor*>(sender());
//VideoFrame frame(e->frame());
view->receive(frame);
qDebug() << frame.format();
qDebug("frame %dx%d", frame.width(), frame.height());
qApp->processEvents();
qDebug("frame %dx%d @%f", frame.width(), frame.height(), frame.timestamp());
}
private:
VideoRenderer *view;
Expand All @@ -53,8 +51,10 @@ int main(int argc, char** argv)
{
QApplication a(argc, argv);
int idx = a.arguments().indexOf("-f");
if (idx < 0)
if (idx < 0) {
qDebug("-f file -t sec -n count -asyc");
return -1;
}
QString file = a.arguments().at(idx+1);
idx = a.arguments().indexOf("-t");
int t = 0;
Expand All @@ -76,6 +76,7 @@ int main(int argc, char** argv)
QElapsedTimer timer;
timer.start();
for (int i = 0; i < n; ++i) {
// async does not work. you have to set a new position when frameExtracted is emitted
extractor.setPosition(t + 1000*i);
}
qDebug("elapsed: %lld", timer.elapsed());
Expand Down

0 comments on commit 568fe86

Please sign in to comment.