Rename video/audio/subtitle part methods.
[dcpomatic.git] / test / time_calculation_test.cc
index 2be49f629c32398597aa77b92908ef027eee8c5f..353a97dd0ec8b4d990a41ee94ef7475d7a1bf1a5 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@
 
 #include "lib/film.h"
 #include "lib/ffmpeg_content.h"
+#include "lib/video_content.h"
 #include "lib/player.h"
 #include "test.h"
 #include <boost/test/unit_test.hpp>
@@ -127,19 +128,19 @@ BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test)
 
        /* 25fps content, 25fps DCP */
        film->set_video_frame_rate (25);
-       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0));
+       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 25.0));
        /* 25fps content, 24fps DCP; length should be increased */
        film->set_video_frame_rate (24);
-       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 24.0));
+       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 24.0));
        /* 25fps content, 30fps DCP; length should be decreased */
        film->set_video_frame_rate (30);
-       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 30.0));
+       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 30.0));
        /* 25fps content, 50fps DCP; length should be the same */
        film->set_video_frame_rate (50);
-       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() / 25.0));
+       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() / 25.0));
        /* 25fps content, 60fps DCP; length should be decreased */
        film->set_video_frame_rate (60);
-       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video_length() * (50.0 / 60) / 25.0));
+       BOOST_CHECK_EQUAL (content->full_length(), DCPTime::from_seconds (content->video->length() * (50.0 / 60) / 25.0));
 }
 
 /** Test Player::dcp_to_content_video */
@@ -152,7 +153,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
 
        list<string> notes;
        shared_ptr<FFmpegContent> content (new FFmpegContent (film, doc, film->state_version(), notes));
-       film->set_sequence_video (false);
+       film->set_sequence (false);
        film->add_content (content);
 
        shared_ptr<Player> player (new Player (film, film->playlist ()));
@@ -160,7 +161,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        /* Position 0, no trim, content rate = DCP rate */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -172,7 +173,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        /* Position 3s, no trim, content rate = DCP rate */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -186,7 +187,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        /* Position 3s, 1.5s trim, content rate = DCP rate */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -203,7 +204,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -215,7 +216,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        /* Position 3s, no trim, content rate 24, DCP rate 25 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -231,7 +232,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
         */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.6));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -250,7 +251,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (48);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -262,7 +263,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        /* Position 3s, no trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (48);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -276,7 +277,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (48);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -294,7 +295,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (48);
+       content->video->set_frame_rate (48);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -306,7 +307,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        /* Position 3s, no trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (48);
+       content->video->set_frame_rate (48);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -320,7 +321,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (48);
+       content->video->set_frame_rate (48);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -330,6 +331,21 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
        BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (3.00)),  72);
        BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (4.50)), 144);
        BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime::from_seconds (9.75)), 396);
+
+       /* Position 0s, no trim, content rate 29.9978733, DCP rate 30 */
+       content->set_position (DCPTime::from_seconds (0));
+       content->set_trim_start (ContentTime::from_seconds (0));
+       content->video->set_frame_rate (29.9978733);
+       film->set_video_frame_rate (30);
+       player->setup_pieces ();
+       BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
+       piece = player->_pieces.front ();
+       BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime ()), 0);
+       BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (3200)), 1);
+       BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (6400)), 2);
+       BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (9600)), 3);
+       BOOST_CHECK_EQUAL (player->dcp_to_content_video (piece, DCPTime (12800)), 4);
+
 }
 
 /** Test Player::content_video_to_dcp */
@@ -342,7 +358,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
 
        list<string> notes;
        shared_ptr<FFmpegContent> content (new FFmpegContent (film, doc, film->state_version(), notes));
-       film->set_sequence_video (false);
+       film->set_sequence (false);
        film->add_content (content);
 
        shared_ptr<Player> player (new Player (film, film->playlist ()));
@@ -350,7 +366,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 0, no trim, content rate = DCP rate */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -362,7 +378,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 3s, no trim, content rate = DCP rate */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -374,7 +390,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 3s, 1.5s trim, content rate = DCP rate */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -390,7 +406,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -402,7 +418,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 3s, no trim, content rate 24, DCP rate 25 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -414,7 +430,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 3s, 1.6s trim, content rate 24, DCP rate 25, so the 1.6s trim is at 24fps */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.6));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -432,7 +448,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (48);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -444,7 +460,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 3s, no trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (48);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -456,7 +472,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (48);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -473,7 +489,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (48);
+       content->video->set_frame_rate (48);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -485,7 +501,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 3s, no trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (48);
+       content->video->set_frame_rate (48);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -497,7 +513,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
        /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (48);
+       content->video->set_frame_rate (48);
        film->set_video_frame_rate (24);
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
@@ -519,7 +535,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        list<string> notes;
        shared_ptr<FFmpegContent> content (new FFmpegContent (film, doc, film->state_version(), notes));
        AudioStreamPtr stream = content->audio_streams().front();
-       film->set_sequence_video (false);
+       film->set_sequence (false);
        film->add_content (content);
 
        shared_ptr<Player> player (new Player (film, film->playlist ()));
@@ -527,7 +543,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 0, no trim, video/audio content rate = video/audio DCP rate */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -540,7 +556,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, no trim, video/audio content rate = video/audio DCP rate */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -555,14 +571,14 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, 1.5s trim, video/audio content rate = video/audio DCP rate */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
        BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
        piece = player->_pieces.front ();
        BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0);
-       BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)),   0);
+       BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.50)),      0);
        BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)),  72000);
        BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000);
        BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000);
@@ -570,7 +586,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 0, no trim, content video rate 24, DCP video rate 25, both audio rates still 48k */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -583,7 +599,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, no trim, content video rate 24, DCP rate 25, both audio rates still 48k. */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -596,12 +612,11 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 324000);
 
        /* Position 3s, 1.6s trim, content rate 24, DCP rate 25, both audio rates still 48k.
-          Since the DCP is faster, and resampled audio is at the DCP rate, our 1.6s trim in
-          content time corresponds to 1.6 * 24 * 48000 / 25 audio samples.
+          1s of content is 46080 samples after resampling.
        */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.6));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (25);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -620,7 +635,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (48);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -633,7 +648,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, no trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -648,7 +663,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -666,7 +681,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (48);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -679,7 +694,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, no trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -694,7 +709,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, 1.5s trim, content rate 24, DCP rate 48 */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 48000;
        player->setup_pieces ();
@@ -709,7 +724,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 0, no trim, video content rate = video DCP rate, content audio rate = 44.1k */
        content->set_position (DCPTime ());
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 44100;
        player->setup_pieces ();
@@ -722,7 +737,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, no trim, video content rate = video DCP rate, content audio rate = 44.1k */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime ());
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 44100;
        player->setup_pieces ();
@@ -737,7 +752,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        /* Position 3s, 1.5s trim, video content rate = video DCP rate, content audio rate = 44.1k */
        content->set_position (DCPTime::from_seconds (3));
        content->set_trim_start (ContentTime::from_seconds (1.5));
-       content->set_video_frame_rate (24);
+       content->video->set_frame_rate (24);
        film->set_video_frame_rate (24);
        stream->_frame_rate = 44100;
        player->setup_pieces ();
@@ -748,4 +763,15 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
        BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.00)),  72000);
        BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (4.50)), 144000);
        BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (9.75)), 396000);
+
+       /* Check with a large start trim */
+       content->set_position (DCPTime::from_seconds (0));
+       content->set_trim_start (ContentTime::from_seconds (54143));
+       content->video->set_frame_rate (24);
+       film->set_video_frame_rate (24);
+       stream->_frame_rate = 48000;
+       player->setup_pieces ();
+       BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1);
+       piece = player->_pieces.front ();
+       BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 54143L * 48000);
 }