Trying to create export audio encoders with between 9 and 15 channels
authorCarl Hetherington <cth@carlh.net>
Mon, 27 Jul 2020 21:52:08 +0000 (23:52 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 28 Jul 2020 09:24:31 +0000 (11:24 +0200)
inclusive fails, at least for AAC.  There's probably a way around
this with some FFmpeg-cleverness but for now let's just export any
project with more than 8 channels as 16.

You could argue that we should offer choices to, for example
export 7.1/HI/VN as 7.1 but that sounds fiddly.

Fixes #1786.

src/lib/ffmpeg_encoder.cc

index 15e27e63355f8e9dab5df0ef3859a2288b46d7d2..a3d2ff86f3446d2429bc2ccb979a8d57cbbd7635 100644 (file)
@@ -61,38 +61,6 @@ FFmpegEncoder::FFmpegEncoder (
        : Encoder (film, job)
        , _history (200)
 {
-       int const files = split_reels ? film->reels().size() : 1;
-       for (int i = 0; i < files; ++i) {
-
-               boost::filesystem::path filename = output;
-               string extension = boost::filesystem::extension (filename);
-               filename = boost::filesystem::change_extension (filename, "");
-
-               if (files > 1) {
-                       /// TRANSLATORS: _reel%1 here is to be added to an export filename to indicate
-                       /// which reel it is.  Preserve the %1; it will be replaced with the reel number.
-                       filename = filename.string() + String::compose(_("_reel%1"), i + 1);
-               }
-
-               _file_encoders.push_back (
-                       FileEncoderSet (
-                               _film->frame_size(),
-                               _film->video_frame_rate(),
-                               _film->audio_frame_rate(),
-                               mixdown_to_stereo ? 2 : film->audio_channels(),
-                               format,
-                               x264_crf,
-                               _film->three_d(),
-                               filename,
-                               extension
-#ifdef DCPOMATIC_VARIANT_SWAROOP
-                               , key
-                               , id
-#endif
-                               )
-                       );
-       }
-
        _player->set_always_burn_open_subtitles ();
        _player->set_play_referenced ();
 
@@ -123,16 +91,52 @@ FFmpegEncoder::FFmpegEncoder (
                }
                /* XXX: maybe we should do something better for >6 channel DCPs */
        } else {
-               _output_audio_channels = ch;
-               map = AudioMapping (ch, ch);
+               /* Our encoders don't really want to encode any channel count between 9 and 15 inclusive,
+                * so let's just use 16 channel exports for any project with more than 8 channels.
+                */
+               _output_audio_channels = ch > 8 ? 16 : ch;
+               map = AudioMapping (ch, _output_audio_channels);
                for (int i = 0; i < ch; ++i) {
                        map.set (i, i, 1);
                }
        }
 
        _butler.reset (new Butler(_player, map, _output_audio_channels, bind(&PlayerVideo::force, _1, FFmpegFileEncoder::pixel_format(format)), true, false));
+
+       int const files = split_reels ? film->reels().size() : 1;
+       for (int i = 0; i < files; ++i) {
+
+               boost::filesystem::path filename = output;
+               string extension = boost::filesystem::extension (filename);
+               filename = boost::filesystem::change_extension (filename, "");
+
+               if (files > 1) {
+                       /// TRANSLATORS: _reel%1 here is to be added to an export filename to indicate
+                       /// which reel it is.  Preserve the %1; it will be replaced with the reel number.
+                       filename = filename.string() + String::compose(_("_reel%1"), i + 1);
+               }
+
+               _file_encoders.push_back (
+                       FileEncoderSet (
+                               _film->frame_size(),
+                               _film->video_frame_rate(),
+                               _film->audio_frame_rate(),
+                               _output_audio_channels,
+                               format,
+                               x264_crf,
+                               _film->three_d(),
+                               filename,
+                               extension
+#ifdef DCPOMATIC_VARIANT_SWAROOP
+                               , key
+                               , id
+#endif
+                               )
+                       );
+       }
 }
 
+
 void
 FFmpegEncoder::go ()
 {