Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,26 @@ options:

Uses the same format as --start-date.

--output-start-date "YYYY-MM-DD hh:mm:ss +tz"
Start outputting frames from this date.

Unlike --start-date which filters log entries, this option simulates
the full repository history but only outputs frames from the specified
date onwards. Files and users will be in their correct positions as if
the entire history had been rendered.

Uses the same format as --start-date.

--output-stop-date "YYYY-MM-DD hh:mm:ss +tz"
Stop outputting frames after this date.

Unlike --stop-date which filters log entries, this option simulates
the full repository history but stops outputting frames after the
specified date. Useful for rendering segments of long repository
histories without processing the entire history multiple times.

Uses the same format as --start-date.

-p, --start-position POSITION
Begin at some position in the log (between 0.0 and 1.0 or 'random').

Expand Down
18 changes: 17 additions & 1 deletion src/gource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,23 @@ void Gource::update(float t, float dt) {
//extract frames based on frameskip setting if frameExporter defined
if(frameExporter != 0 && commitlog && !gGourceSettings.shutdown) {
if(framecount % (frameskip+1) == 0) {
frameExporter->dump();
// Check if current simulation time is within output date range
bool in_output_range = true;

// Skip frames before output-start-date
if(gGourceSettings.output_start_timestamp != 0 && currtime < gGourceSettings.output_start_timestamp) {
in_output_range = false;
}

// Skip frames after output-stop-date and mark as finished
if(gGourceSettings.output_stop_timestamp != 0 && currtime > gGourceSettings.output_stop_timestamp) {
in_output_range = false;
stop_position_reached = true;
}

if(in_output_range) {
frameExporter->dump();
}
}
}

Expand Down
55 changes: 55 additions & 0 deletions src/gource_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ void GourceSettings::help(bool extended_help) {

printf(" --start-date 'YYYY-MM-DD hh:mm:ss +tz' Start at a date and optional time\n");
printf(" --stop-date 'YYYY-MM-DD hh:mm:ss +tz' Stop at a date and optional time\n\n");
printf(" --output-start-date 'YYYY-MM-DD hh:mm:ss +tz'\n");
printf(" Start outputting frames from this date\n");
printf(" --output-stop-date 'YYYY-MM-DD hh:mm:ss +tz'\n");
printf(" Stop outputting frames after this date\n\n");
printf(" -p, --start-position POSITION Start at some position (0.0-1.0 or 'random')\n");
printf(" --stop-position POSITION Stop at some position\n");
printf(" -t, --stop-at-time SECONDS Stop after a specified number of seconds\n");
Expand Down Expand Up @@ -340,6 +344,8 @@ GourceSettings::GourceSettings() {
arg_types["start-position"] = "string";
arg_types["start-date"] = "string";
arg_types["stop-date"] = "string";
arg_types["output-start-date"] = "string";
arg_types["output-stop-date"] = "string";
arg_types["stop-position"] = "string";
arg_types["crop"] = "string";
arg_types["hide"] = "string";
Expand Down Expand Up @@ -390,6 +396,12 @@ void GourceSettings::setGourceDefaults() {
stop_timestamp = 0;
stop_date = "";

output_start_timestamp = 0;
output_start_date = "";

output_stop_timestamp = 0;
output_stop_date = "";

start_position = 0.0f;
stop_position = 0.0f;
stop_at_time = -1.0f;
Expand Down Expand Up @@ -1311,6 +1323,49 @@ void GourceSettings::importGourceSettings(ConfFile& conffile, ConfSection* gourc
}
}

if((entry = gource_settings->getEntry("output-start-date")) != 0) {

if(!entry->hasValue()) conffile.entryException(entry, "specify output-start-date (YYYY-MM-DD hh:mm:ss)");

std::string output_start_date_string = entry->getString();

if(parseDateTime(output_start_date_string, output_start_timestamp)) {

char datestr[256];
strftime(datestr, 256, "%Y-%m-%d", localtime ( &output_start_timestamp ));
output_start_date = datestr;

} else {
conffile.invalidValueException(entry);
}
}

if((entry = gource_settings->getEntry("output-stop-date")) != 0) {

if(!entry->hasValue()) conffile.entryException(entry, "specify output-stop-date (YYYY-MM-DD hh:mm:ss)");

std::string output_stop_date_string = entry->getString();

if(parseDateTime(output_stop_date_string, output_stop_timestamp)) {

struct tm * timeinfo;
timeinfo = localtime ( &output_stop_timestamp );

time_t output_stop_timestamp_rounded = output_stop_timestamp;

if(timeinfo->tm_hour > 0 || timeinfo->tm_min > 0 || timeinfo->tm_sec > 0) {
output_stop_timestamp_rounded += 60*60*24;
}

char datestr[256];
strftime(datestr, 256, "%Y-%m-%d", localtime ( &output_stop_timestamp_rounded ));
output_stop_date = datestr;

} else {
conffile.invalidValueException(entry);
}
}

if((entry = gource_settings->getEntry("start-position")) != 0) {

if(!entry->hasValue()) conffile.entryException(entry, "specify start-position (float,random)");
Expand Down
5 changes: 5 additions & 0 deletions src/gource_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class GourceSettings : public SDLAppSettings {
time_t start_timestamp;
time_t stop_timestamp;

std::string output_start_date;
std::string output_stop_date;
time_t output_start_timestamp;
time_t output_stop_timestamp;

float start_position;
float stop_position;
float stop_at_time;
Expand Down