Skip to content

Commit dfebaf5

Browse files
authored
Stream History (#1073)
* Stream History: switch back to using SaveFrames.h * draft: save compressed frames. * fix build * split StreamHistory tracker into .h and .cpp file. add draft VideoGenerator class. * initial working implementation of saving frames to video. * reduce video file size * reduce fps * adjust implementation of variable FPS * add options to change FPS, JPEG quality. * re-enable StreamHistoryTracker_Null * remove old code. * update StreamHistoryOption text * move compression to separate thread. * Insert dummy frames if there is a gap due to dropping frames, to preserve frame rate * add comments * use Thread wrapper to replace std::thread * remove unused headers * insert duplicate frames based on frame index instead of incrementing a fixed frame interval. * add logging * fix initialization of m_next_frame_time
1 parent 6a25e7d commit dfebaf5

File tree

6 files changed

+777
-253
lines changed

6 files changed

+777
-253
lines changed

SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.cpp

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ StreamHistoryOption::StreamHistoryOption()
1717
true
1818
)
1919
, DESCRIPTION(
20-
"Keep a record of the recent video+audio streams. This will allow video capture "
20+
"Keep a record of the recent video streams. This will allow video capture "
2121
"for unexpected events.<br><br>"
22-
"<font color=\"red\">Warning: This feature has a known memory leak. It will leak ~3GB per day per "
23-
"video stream. You have been warned!</font>"
24-
"<br><br>"
22+
// "<font color=\"red\">Warning: This feature has a known memory leak. It will leak ~3GB per day per "
23+
// "video stream. You have been warned!</font>"
24+
// "<br><br>"
2525
"<font color=\"orange\">Warning: This feature is computationally expensive and "
2626
"will require a more powerful computer to run (especially for multi-Switch programs).<br>"
27-
"Furthermore, the current implementation is inefficient as it will write a lot "
28-
"of data to disk. This feature is still a work-in-progress."
27+
// "Furthermore, the current implementation is inefficient as it will write a lot "
28+
// "of data to disk. This feature is still a work-in-progress."
2929
"</font>"
3030
)
3131
, HISTORY_SECONDS(
@@ -80,13 +80,39 @@ StreamHistoryOption::StreamHistoryOption()
8080
LockMode::UNLOCK_WHILE_RUNNING,
8181
5000
8282
)
83+
, VIDEO_FPS(
84+
"<b>Video Frames per second:</b><br>"
85+
"Lower = choppier video, smaller file size.<br>"
86+
"Higher = smoother video, larger file size.",
87+
{
88+
// {VideoFPS::MATCH_INPUT, "match", "Match Input FPS"},
89+
{VideoFPS::FPS_30, "fps-30", "30 FPS"},
90+
{VideoFPS::FPS_15, "fps-15", "15 FPS"},
91+
{VideoFPS::FPS_10, "fps-10", "10 FPS"},
92+
{VideoFPS::FPS_05, "fps-05", "5 FPS"},
93+
{VideoFPS::FPS_01, "fps-01", "1 FPS"},
94+
},
95+
LockMode::UNLOCK_WHILE_RUNNING,
96+
VideoFPS::FPS_15
97+
)
98+
, JPEG_QUALITY(
99+
"<b>JPEG Quality:</b><br>"
100+
"Video frames are compressed into JPEGs to save space in RAM.<br>"
101+
"Lower = lower quality, lower RAM usage.<br>"
102+
"Higher = high quality, higher RAM usage.",
103+
LockMode::UNLOCK_WHILE_RUNNING,
104+
80,
105+
0, 100
106+
)
83107
{
84108
PA_ADD_STATIC(DESCRIPTION);
85109
PA_ADD_OPTION(HISTORY_SECONDS);
86110
PA_ADD_OPTION(RESOLUTION);
87-
PA_ADD_OPTION(ENCODING_MODE);
88-
PA_ADD_OPTION(VIDEO_QUALITY);
89-
PA_ADD_OPTION(VIDEO_BITRATE);
111+
PA_ADD_OPTION(VIDEO_FPS);
112+
PA_ADD_OPTION(JPEG_QUALITY);
113+
// PA_ADD_OPTION(ENCODING_MODE);
114+
// PA_ADD_OPTION(VIDEO_QUALITY);
115+
// PA_ADD_OPTION(VIDEO_BITRATE);
90116

91117
StreamHistoryOption::on_config_value_changed(this);
92118

SerialPrograms/Source/CommonFramework/Recording/StreamHistoryOption.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ class StreamHistoryOption : public GroupOption, public ConfigOption::Listener{
4949
};
5050
EnumDropdownOption<VideoQuality> VIDEO_QUALITY;
5151
SimpleIntegerOption<uint32_t> VIDEO_BITRATE;
52+
53+
enum class VideoFPS{
54+
// MATCH_INPUT,
55+
FPS_30,
56+
FPS_15,
57+
FPS_10,
58+
FPS_05,
59+
FPS_01,
60+
};
61+
EnumDropdownOption<VideoFPS> VIDEO_FPS;
62+
SimpleIntegerOption<uint16_t> JPEG_QUALITY;
5263
};
5364

5465

SerialPrograms/Source/CommonFramework/Recording/StreamHistorySession.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
#include "CommonFramework/Recording/StreamHistoryOption.h"
1414

1515
#if (QT_VERSION_MAJOR == 6) && (QT_VERSION_MINOR >= 8)
16-
//#include "StreamHistoryTracker_SaveFrames.h"
16+
#include "StreamHistoryTracker_SaveFrames.h"
1717
//#include "StreamHistoryTracker_RecordOnTheFly.h"
18-
#include "StreamHistoryTracker_ParallelStreams.h"
18+
// #include "StreamHistoryTracker_ParallelStreams.h"
1919
#else
2020
#include "StreamHistoryTracker_Null.h"
2121
#endif

0 commit comments

Comments
 (0)