+
+string format_duration(TimeRemaining t)
+{
+ int t_ms = lrint(t.t * 1e3);
+
+ int ms = t_ms % 1000;
+ t_ms /= 1000;
+ int s = t_ms % 60;
+ t_ms /= 60;
+ int m = t_ms;
+
+ char buf[256];
+ if (t.num_infinite > 1 && t.t > 0.0) {
+ snprintf(buf, sizeof(buf), "%zu clips + %d:%02d.%03d", t.num_infinite, m, s, ms);
+ } else if (t.num_infinite > 1) {
+ snprintf(buf, sizeof(buf), "%zu clips", t.num_infinite);
+ } else if (t.num_infinite == 1 && t.t > 0.0) {
+ snprintf(buf, sizeof(buf), "%zu clip + %d:%02d.%03d", t.num_infinite, m, s, ms);
+ } else if (t.num_infinite == 1) {
+ snprintf(buf, sizeof(buf), "%zu clip", t.num_infinite);
+ } else {
+ snprintf(buf, sizeof(buf), "%d:%02d.%03d", m, s, ms);
+ }
+ return buf;
+}