mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-08 00:58:20 +02:00
Framerate is stable, and GIF duration is correctgit add -A!
This commit is contained in:
parent
25471d9fae
commit
8f9ffd2bc5
2 changed files with 23 additions and 17 deletions
|
@ -5428,12 +5428,11 @@ void Application::toggleLogDialog() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is "too big" (which depends on PC spec):
|
// If the snapshot width or the framerate are too high for the
|
||||||
// The frame will take too long to pack, the timer slot will
|
// application to handle, the framerate of the output GIF will drop.
|
||||||
// not execute properly, and the GIF will appear sped-up.
|
#define SNAPSNOT_ANIMATED_WIDTH (720)
|
||||||
// This is unacceptable and is probably a blocker for release.
|
// This value should divide evenly into 100. Snapshot framerate is NOT guaranteed.
|
||||||
#define SNAPSNOT_ANIMATED_WIDTH (400)
|
#define SNAPSNOT_ANIMATED_FRAMERATE_FPS (25)
|
||||||
#define SNAPSNOT_ANIMATED_FRAMERATE_FPS (25) // This value should divide evenly into 100
|
|
||||||
#define SNAPSNOT_ANIMATED_DURATION_SECS (3)
|
#define SNAPSNOT_ANIMATED_DURATION_SECS (3)
|
||||||
|
|
||||||
#define SNAPSNOT_ANIMATED_FRAME_DELAY_MSEC (1000/SNAPSNOT_ANIMATED_FRAMERATE_FPS)
|
#define SNAPSNOT_ANIMATED_FRAME_DELAY_MSEC (1000/SNAPSNOT_ANIMATED_FRAMERATE_FPS)
|
||||||
|
@ -5497,15 +5496,6 @@ void Application::takeSnapshot(bool notify, float aspectRatio) {
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Write the frame to the gif
|
|
||||||
GifWriteFrame(&(qApp->_animatedSnapshotGifWriter),
|
|
||||||
(uint8_t*)frame.bits(),
|
|
||||||
frame.width(),
|
|
||||||
frame.height(),
|
|
||||||
round(((float)(QDateTime::currentMSecsSinceEpoch() - qApp->_animatedSnapshotTimestamp)) / 10));
|
|
||||||
// Record the current frame timestamp
|
|
||||||
qApp->_animatedSnapshotTimestamp = QDateTime::currentMSecsSinceEpoch();
|
|
||||||
|
|
||||||
// If that was the last frame...
|
// If that was the last frame...
|
||||||
if ((qApp->_animatedSnapshotTimestamp - qApp->_animatedSnapshotFirstFrameTimestamp) >= (SNAPSNOT_ANIMATED_DURATION_SECS * 1000))
|
if ((qApp->_animatedSnapshotTimestamp - qApp->_animatedSnapshotFirstFrameTimestamp) >= (SNAPSNOT_ANIMATED_DURATION_SECS * 1000))
|
||||||
{
|
{
|
||||||
|
@ -5519,6 +5509,21 @@ void Application::takeSnapshot(bool notify, float aspectRatio) {
|
||||||
// Stop the snapshot QTimer
|
// Stop the snapshot QTimer
|
||||||
qApp->animatedSnapshotTimer.stop();
|
qApp->animatedSnapshotTimer.stop();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Variable used to determine how long the current frame took to pack
|
||||||
|
qint64 temp = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
// Write the frame to the gif
|
||||||
|
GifWriteFrame(&(qApp->_animatedSnapshotGifWriter),
|
||||||
|
(uint8_t*)frame.bits(),
|
||||||
|
frame.width(),
|
||||||
|
frame.height(),
|
||||||
|
round(((float)(QDateTime::currentMSecsSinceEpoch() - qApp->_animatedSnapshotTimestamp + qApp->_animatedSnapshotLastWriteFrameDuration)) / 10));
|
||||||
|
// Record how long it took for the current frame to pack
|
||||||
|
qApp->_animatedSnapshotLastWriteFrameDuration = QDateTime::currentMSecsSinceEpoch() - temp;
|
||||||
|
// Record the current frame timestamp
|
||||||
|
qApp->_animatedSnapshotTimestamp = QDateTime::currentMSecsSinceEpoch();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -613,8 +613,9 @@ private:
|
||||||
|
|
||||||
QTimer animatedSnapshotTimer;
|
QTimer animatedSnapshotTimer;
|
||||||
GifWriter _animatedSnapshotGifWriter;
|
GifWriter _animatedSnapshotGifWriter;
|
||||||
quint64 _animatedSnapshotTimestamp{ 0 };
|
qint64 _animatedSnapshotTimestamp { 0 };
|
||||||
quint64 _animatedSnapshotFirstFrameTimestamp{ 0 };
|
qint64 _animatedSnapshotFirstFrameTimestamp { 0 };
|
||||||
|
qint64 _animatedSnapshotLastWriteFrameDuration { 20 };
|
||||||
QString _animatedSnapshotPath;
|
QString _animatedSnapshotPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue