diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-06-14 22:12:51 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-06-14 22:12:51 +0200 |
| commit | a863000bf1b7bdcd67286206916f5f9c4fdbd844 (patch) | |
| tree | 1909ee4551feb85b19c56d6179aeba21b43bf5ce | |
| parent | 46c1a60d39c09d2212aca0404bd11b51cf440a88 (diff) | |
Fix error when exporting stereo projects with "mixdown to stereo"v2.15.79
set.
| -rw-r--r-- | src/lib/ffmpeg_encoder.cc | 24 | ||||
| -rw-r--r-- | test/ffmpeg_encoder_test.cc | 17 |
2 files changed, 35 insertions, 6 deletions
diff --git a/src/lib/ffmpeg_encoder.cc b/src/lib/ffmpeg_encoder.cc index 61e489f07..ee49a0646 100644 --- a/src/lib/ffmpeg_encoder.cc +++ b/src/lib/ffmpeg_encoder.cc @@ -104,12 +104,24 @@ FFmpegEncoder::FFmpegEncoder ( map = AudioMapping (ch, 2); float const overall_gain = 2 / (4 + sqrt(2)); float const minus_3dB = 1 / sqrt(2); - map.set (dcp::LEFT, 0, overall_gain); - map.set (dcp::RIGHT, 1, overall_gain); - map.set (dcp::CENTRE, 0, overall_gain * minus_3dB); - map.set (dcp::CENTRE, 1, overall_gain * minus_3dB); - map.set (dcp::LS, 0, overall_gain); - map.set (dcp::RS, 1, overall_gain); + if (ch == 2) { + map.set (dcp::LEFT, 0, 1); + map.set (dcp::RIGHT, 1, 1); + } else if (ch == 4) { + map.set (dcp::LEFT, 0, overall_gain); + map.set (dcp::RIGHT, 1, overall_gain); + map.set (dcp::CENTRE, 0, overall_gain * minus_3dB); + map.set (dcp::CENTRE, 1, overall_gain * minus_3dB); + map.set (dcp::LS, 0, overall_gain); + } else if (ch >= 6) { + map.set (dcp::LEFT, 0, overall_gain); + map.set (dcp::RIGHT, 1, overall_gain); + map.set (dcp::CENTRE, 0, overall_gain * minus_3dB); + map.set (dcp::CENTRE, 1, overall_gain * minus_3dB); + map.set (dcp::LS, 0, overall_gain); + map.set (dcp::RS, 1, overall_gain); + } + /* XXX: maybe we should do something better for >6 channel DCPs */ } else { _output_audio_channels = ch; map = AudioMapping (ch, ch); diff --git a/test/ffmpeg_encoder_test.cc b/test/ffmpeg_encoder_test.cc index 10186abcc..d824ede30 100644 --- a/test/ffmpeg_encoder_test.cc +++ b/test/ffmpeg_encoder_test.cc @@ -376,3 +376,20 @@ BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test7) encoder.go (); } + +/** Stereo project with mixdown-to-stereo set */ +BOOST_AUTO_TEST_CASE (ffmpeg_encoder_h264_test8) +{ + shared_ptr<Film> film = new_test_film2("ffmpeg_encoder_h264_test4"); + film->examine_and_add_content(shared_ptr<DCPContent>(new DCPContent("test/data/scope_dcp"))); + BOOST_REQUIRE(!wait_for_jobs()); + film->set_audio_channels (2); + + shared_ptr<Job> job(new TranscodeJob(film)); + FFmpegEncoder encoder(film, job, "build/test/ffmpeg_encoder_h264_test8.mp4", EXPORT_FORMAT_H264_AAC, true, false, 23 +#ifdef DCPOMATIC_VARIANT_SWAROOP + , optional<dcp::Key>(), optional<string>() +#endif + ); + encoder.go(); +} |
