/*
- Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
path = file (metadata_file);
}
+ if (!boost::filesystem::exists(*path)) {
+ throw FileNotFoundError(*path);
+ }
+
cxml::Document f ("Metadata");
f.read_file (path.get ());
_playlist->move_later (shared_from_this(), c);
}
-/** @return length of the film from time 0 to the last thing on the playlist */
+/** @return length of the film from time 0 to the last thing on the playlist,
+ * with a minimum length of 1 second.
+ */
DCPTime
Film::length () const
{
- return _playlist->length(shared_from_this()).ceil(video_frame_rate());
+ return max(DCPTime::from_seconds(1), _playlist->length(shared_from_this()).ceil(video_frame_rate()));
}
int
split_points.sort ();
split_points.unique ();
- /* Make them into periods */
+ /* Make them into periods, coalescing any that are less than 1 second long */
optional<DCPTime> last;
BOOST_FOREACH (DCPTime t, split_points) {
- if (last) {
+ 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;
}
- last = t;
}
break;
}
case REELTYPE_BY_LENGTH:
{
DCPTime current;
- /* Integer-divide reel length by the size of one frame to give the number of frames per reel */
- Frame const reel_in_frames = _reel_length / ((j2k_bandwidth() / video_frame_rate()) / 8);
+ /* Integer-divide reel length by the size of one frame to give the number of frames per reel,
+ * making sure we don't go less than 1s long.
+ */
+ Frame const reel_in_frames = max(_reel_length / ((j2k_bandwidth() / video_frame_rate()) / 8), static_cast<Frame>(video_frame_rate()));
while (current < len) {
DCPTime end = min (len, current + DCPTime::from_frames (reel_in_frames, video_frame_rate ()));
p.push_back (DCPTimePeriod (current, end));