Scale subtitle times with frame rate change if they are part of a piece of video...
authorCarl Hetherington <cth@carlh.net>
Tue, 14 Jan 2014 10:39:07 +0000 (10:39 +0000)
committerCarl Hetherington <cth@carlh.net>
Tue, 14 Jan 2014 10:39:07 +0000 (10:39 +0000)
ChangeLog
src/lib/ffmpeg_decoder.cc
src/lib/player.cc

index b35298c88d86467a53e1ff3ca9b897d11d3cb98e..fadc8f509b4381a7e34769bd31bec17c38ac099e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-14  Carl Hetherington  <cth@carlh.net>
+
+       * Try to fix subtitle problems when the video frame rate is being changed
+       from content to DCP.
+
 2014-01-13  Carl Hetherington  <cth@carlh.net>
 
        * Change 4:3 and 5:3 ratios to be precise rather than 1.33:1 and 1.66:1, and
index b672b2c1fd6e571dbc5140b30c43729888bb38cd..a6f9a17c3bc7978e91821e64758f1be52a2361b6 100644 (file)
@@ -556,7 +556,7 @@ FFmpegDecoder::decode_subtitle_packet ()
           source that we may have chopped off for the DCP)
        */
        double const packet_time = (static_cast<double> (sub.pts ) / AV_TIME_BASE) + _video_pts_offset;
-       
+
        /* hence start time for this sub */
        Time const from = (packet_time + (double (sub.start_display_time) / 1e3)) * TIME_HZ;
        Time const to = (packet_time + (double (sub.end_display_time) / 1e3)) * TIME_HZ;
index 9f859969341fa65a1eacc22d0c3da9b7002387c0..56145f5bdec1f7a6fa7cd218702d8f211d98907b 100644 (file)
@@ -292,6 +292,7 @@ Player::process_video (weak_ptr<Piece> weak_piece, shared_ptr<const Image> image
 
                pi->set_subtitle (_out_subtitle.image, _out_subtitle.position + container_offset);
        }
+               
                                            
 #ifdef DCPOMATIC_DEBUG
        _last_video = piece->content;
@@ -683,8 +684,18 @@ Player::update_subtitle ()
                _in_subtitle.image->pixel_format (),
                true
                );
-       _out_subtitle.from = _in_subtitle.from + piece->content->position ();
-       _out_subtitle.to = _in_subtitle.to + piece->content->position ();
+
+       /* XXX: hack */
+       Time from = _in_subtitle.from;
+       Time to = _in_subtitle.to;
+       shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (piece->content);
+       if (vc) {
+               from = rint (from * vc->video_frame_rate() / _film->video_frame_rate());
+               to = rint (to * vc->video_frame_rate() / _film->video_frame_rate());
+       }
+       
+       _out_subtitle.from = from * piece->content->position ();
+       _out_subtitle.to = to + piece->content->position ();
 }
 
 /** Re-emit the last frame that was emitted, using current settings for crop, ratio, scaler and subtitles.