Slightly hacky fix for -114 errors during 3D encodes (#2173). v2.15.188
authorCarl Hetherington <cth@carlh.net>
Thu, 20 Jan 2022 20:23:09 +0000 (21:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 24 Jan 2022 15:01:25 +0000 (16:01 +0100)
It still feels like I'm missing some large and beautiful trick
with gathering all the gap-filling code into one place, but
such a trick still eludes me.

src/lib/player.cc
test/threed_test.cc

index 4e586ed777252cd4654f8ab5368c811a47306e37..42c22ab7d890db6eab8d80272fec54174cb524e7 100644 (file)
@@ -812,6 +812,19 @@ Player::pass ()
                for (auto const& i: _delay) {
                        do_emit_video(i.first, i.second);
                }
+
+               /* Perhaps we should have Empty entries for both eyes in the 3D case (somehow).
+                * However, if we have L and R video files, and one is shorter than the other,
+                * the fill code in ::video mostly takes care of filling in the gaps.
+                * However, since it fills at the point when it knows there is more video coming
+                * at time t (so it should fill any gap up to t) it can't do anything right at the
+                * end.  This is particularly bad news if the last frame emitted is a LEFT
+                * eye, as the MXF writer will complain about the 3D sequence being wrong.
+                * Here's a hack to workaround that particular case.
+                */
+               if (_next_video_eyes && _next_video_time && *_next_video_eyes == Eyes::RIGHT) {
+                       do_emit_video (black_player_video_frame(Eyes::RIGHT), *_next_video_time);
+               }
        }
 
        return done;
index bceb6700fe1d7bad834626dba3ea5569e1b73f1f..0dd163035c4f087e3a542b3696a519334f28022a 100644 (file)
@@ -212,3 +212,45 @@ BOOST_AUTO_TEST_CASE (threed_test7)
 
        JobManager::drop ();
 }
+
+
+/** Trigger a -114 error by trying to make a 3D DCP out of two files with slightly
+ *  different lengths.
+ */
+BOOST_AUTO_TEST_CASE (threed_test_separate_files_slightly_different_lengths)
+{
+       shared_ptr<Film> film = new_test_film2 ("threed_test3");
+       auto L = make_shared<FFmpegContent>("test/data/test.mp4");
+       film->examine_and_add_content (L);
+       auto R = make_shared<FFmpegContent>("test/data/test.mp4");
+       film->examine_and_add_content (R);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       L->video->set_frame_type (VideoFrameType::THREE_D_LEFT);
+       R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT);
+       R->set_trim_end (dcpomatic::ContentTime::from_frames(1, 24));
+
+       film->set_three_d (true);
+       make_and_verify_dcp (film);
+}
+
+
+/** Trigger a -114 error by trying to make a 3D DCP out of two files with very
+ *  different lengths.
+ */
+BOOST_AUTO_TEST_CASE (threed_test_separate_files_very_different_lengths)
+{
+       shared_ptr<Film> film = new_test_film2 ("threed_test3");
+       auto L = make_shared<FFmpegContent>("test/data/test.mp4");
+       film->examine_and_add_content (L);
+       auto R = make_shared<FFmpegContent>("test/data/test.mp4");
+       film->examine_and_add_content (R);
+       BOOST_REQUIRE (!wait_for_jobs());
+
+       L->video->set_frame_type (VideoFrameType::THREE_D_LEFT);
+       R->video->set_frame_type (VideoFrameType::THREE_D_RIGHT);
+       R->set_trim_end (dcpomatic::ContentTime::from_seconds(1.5));
+
+       film->set_three_d (true);
+       make_and_verify_dcp (film);
+}