X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fsubrip.cc;h=11ad3302d3659abf107eed8b8fa69d33d8109c69;hb=cf8bbea2de38c4e9ac140f55b27311b7b6dcd814;hp=aa4a0b548b88bae467fb68aad33db4ff07b7740f;hpb=cfd4beb36642439db23603f9b8099294761e4624;p=dcpomatic.git diff --git a/src/lib/subrip.cc b/src/lib/subrip.cc index aa4a0b548..11ad3302d 100644 --- a/src/lib/subrip.cc +++ b/src/lib/subrip.cc @@ -66,13 +66,18 @@ SubRip::SubRip (shared_ptr content) switch (state) { case COUNTER: { + if (line.empty ()) { + /* a blank line at the start is ok */ + break; + } + int x = 0; try { x = lexical_cast (line); } catch (...) { } - + if (x == next_count) { state = METADATA; ++next_count; @@ -90,8 +95,7 @@ SubRip::SubRip (shared_ptr content) throw SubRipError (line, _("a time/position line"), content->path (0)); } - current->from = convert_time (p[0]); - current->to = convert_time (p[2]); + current->period = ContentTimePeriod (convert_time (p[0]), convert_time (p[2])); if (p.size() > 3) { current->x1 = convert_coordinate (p[3]); @@ -138,7 +142,7 @@ SubRip::convert_time (string t) vector b; boost::algorithm::split (b, a[2], boost::is_any_of (",")); r += ContentTime::from_seconds (lexical_cast (b[0])); - r += ContentTime::from_seconds (lexical_cast (b[1]) / 1000); + r += ContentTime::from_seconds (lexical_cast (b[1]) / 1000); return r; } @@ -233,5 +237,5 @@ SubRip::length () const return ContentTime (); } - return _subtitles.back().to; + return _subtitles.back().period.to; }