Basics of noting subtitle times in FFmpegSubtitleStreams.
[dcpomatic.git] / src / lib / util.cc
index 14dfd1fa558b6afa86c7dc03a2b05b139d9bce4d..6e370f577d9c8799126499564a24128709c24af3 100644 (file)
@@ -982,3 +982,16 @@ ScopedTemporary::close ()
                _open = 0;
        }
 }
+
+ContentTimePeriod
+subtitle_period (AVSubtitle const & sub)
+{
+       ContentTime const packet_time = ContentTime::from_seconds (static_cast<double> (sub.pts) / AV_TIME_BASE);
+
+       ContentTimePeriod period (
+               packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3),
+               packet_time + ContentTime::from_seconds (sub.end_display_time / 1e3)
+               );
+
+       return period;
+}