diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 54039c3fea..f2301353b1 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -5428,12 +5428,11 @@ void Application::toggleLogDialog() { } } -// If this is "too big" (which depends on PC spec): -// The frame will take too long to pack, the timer slot will -// not execute properly, and the GIF will appear sped-up. -// This is unacceptable and is probably a blocker for release. -#define SNAPSNOT_ANIMATED_WIDTH (400) -#define SNAPSNOT_ANIMATED_FRAMERATE_FPS (25) // This value should divide evenly into 100 +// If the snapshot width or the framerate are too high for the +// application to handle, the framerate of the output GIF will drop. +#define SNAPSNOT_ANIMATED_WIDTH (720) +// This value should divide evenly into 100. Snapshot framerate is NOT guaranteed. +#define SNAPSNOT_ANIMATED_FRAMERATE_FPS (25) #define SNAPSNOT_ANIMATED_DURATION_SECS (3) #define SNAPSNOT_ANIMATED_FRAME_DELAY_MSEC (1000/SNAPSNOT_ANIMATED_FRAMERATE_FPS) @@ -5497,15 +5496,6 @@ void Application::takeSnapshot(bool notify, float aspectRatio) { } 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 ((qApp->_animatedSnapshotTimestamp - qApp->_animatedSnapshotFirstFrameTimestamp) >= (SNAPSNOT_ANIMATED_DURATION_SECS * 1000)) { @@ -5519,6 +5509,21 @@ void Application::takeSnapshot(bool notify, float aspectRatio) { // Stop the snapshot QTimer 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(); + } } }); diff --git a/interface/src/Application.h b/interface/src/Application.h index 092b2d6c1d..49ad9ec03b 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -613,8 +613,9 @@ private: QTimer animatedSnapshotTimer; GifWriter _animatedSnapshotGifWriter; - quint64 _animatedSnapshotTimestamp{ 0 }; - quint64 _animatedSnapshotFirstFrameTimestamp{ 0 }; + qint64 _animatedSnapshotTimestamp { 0 }; + qint64 _animatedSnapshotFirstFrameTimestamp { 0 }; + qint64 _animatedSnapshotLastWriteFrameDuration { 20 }; QString _animatedSnapshotPath; };