- DCPTime video_end = last_video ? last_video->end(shared_from_this()) : DCPTime(0);
- if (last_split) {
- /* Definitely go from the last split to the end of the video content */
- p.push_back (DCPTimePeriod (last_split.get(), video_end));
- }
-
- if (video_end < len) {
- /* And maybe go after that as well if there is any non-video hanging over the end */
- p.push_back (DCPTimePeriod (video_end, len));
+ split_points.sort ();
+ split_points.unique ();
+
+ /* Make them into periods, coalescing any that are less than 1 second long */
+ optional<DCPTime> last;
+ BOOST_FOREACH (DCPTime t, split_points) {
+ if (last && (t - *last) >= DCPTime::from_seconds(1)) {
+ /* Period from *last to t is long enough; use it and start a new one */
+ p.push_back (DCPTimePeriod(*last, t));
+ last = t;
+ } else if (!last) {
+ /* That was the first time, so start a new period */
+ last = t;
+ }