Skip to content

Commit

Permalink
capture name using video timestamp. resolution is 1ms
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Nov 20, 2012
1 parent 98592d0 commit 1df22e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 143,7 @@ void AVPlayer::setCaptureSaveDir(const QString &dir)

bool AVPlayer::capture()
{
double pts = clock->value();
double pts = clock->videoPts();
QImage cap = renderer->currentFrameImage();
if (cap.isNull()) {
qWarning("Null image");
Expand All @@ -160,7 160,7 @@ bool AVPlayer::capture()
cap_path = QFileInfo(path).completeBaseName();
else
cap_path = capture_name;
cap_path = "_" QString::number(pts, 'f') ".jpg";
cap_path = "_" QString::number(pts, 'f', 3) ".jpg";
qDebug("Saving capture to [%s]", qPrintable(cap_path));
if (!cap.save(cap_path, "jpg")) {
qWarning("Save capture failed");
Expand Down
15 changes: 13 additions & 2 deletions src/QtAV/AVClock.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 35,14 @@ class Q_EXPORT AVClock
inline double pts() const;
inline double value() const; //the real timestamp: pts delay
inline void updateValue(double pts); //update the pts

inline void updateVideoPts(double pts);
inline double videoPts() const;
inline double delay() const; //playing audio spends some time
inline void updateDelay(double delay);

private:
ClockType clock_type;
double pts_;
double pts_, pts_v;
double delay_;
};

Expand All @@ -55,6 56,16 @@ void AVClock::updateValue(double pts)
pts_ = pts;
}

void AVClock::updateVideoPts(double pts)
{
pts_v = pts;
}

double AVClock::videoPts() const
{
return pts_v;
}

double AVClock::delay() const
{
return delay_;
Expand Down
1 change: 1 addition & 0 deletions src/VideoThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 77,7 @@ void VideoThread::run()
//continue;
}
}
d.clock->updateVideoPts(pkt.pts); //here?
if (d.dec->decode(pkt.data)) {
if (d.writer)
d.writer->write(d.dec->data());
Expand Down

0 comments on commit 1df22e9

Please sign in to comment.