Speculative support for multi-part subtitles (#709).
[dcpomatic.git] / src / lib / ffmpeg_examiner.cc
index 6173e041529444ed9e2c6cf9e0c8ec305d554bf5..40fe0d28ec5cae2e6bc89d800dd9ef57bb195402 100644 (file)
@@ -30,6 +30,7 @@ extern "C" {
 #include "ffmpeg_subtitle_stream.h"
 #include "util.h"
 #include "safe_stringstream.h"
+#include <boost/foreach.hpp>
 #include <iostream>
 
 #include "i18n.h"
@@ -145,6 +146,16 @@ FFmpegExaminer::FFmpegExaminer (shared_ptr<const FFmpegContent> c, shared_ptr<Jo
                                );
                }
        }
+
+       /* We just added subtitles to our streams without taking the PTS offset into account;
+          this is because we might not know the PTS offset when the first subtitle is seen.
+          Now we know the PTS offset so we can apply it to those subtitles.
+       */
+       if (video_frame_rate()) {
+               BOOST_FOREACH (shared_ptr<FFmpegSubtitleStream> i, _subtitle_streams) {
+                       i->add_offset (pts_offset (_audio_streams, _first_video, video_frame_rate().get()));
+               }
+       }
 }
 
 void