+ , _output (output)
+ , _format (format)
+ , _split_reels (split_reels)
+ , _audio_stream_per_channel (audio_stream_per_channel)
+ , _x264_crf (x264_crf)
+ , _butler(
+ _film,
+ _player,
+ mixdown_to_stereo ? stereo_map() : many_channel_map(),
+ _output_audio_channels,
+ boost::bind(&PlayerVideo::force, FFmpegFileEncoder::pixel_format(format)),
+ VideoRange::VIDEO,
+ Image::Alignment::PADDED,
+ false,
+ false,
+ Butler::Audio::ENABLED
+ )
+{
+ _player.set_always_burn_open_subtitles();
+ _player.set_play_referenced();
+}
+
+
+AudioMapping
+FFmpegEncoder::stereo_map() const
+{
+ auto map = AudioMapping(_film->audio_channels(), 2);
+ float const overall_gain = 2 / (4 + sqrt(2));
+ float const minus_3dB = 1 / sqrt(2);
+ switch (_film->audio_channels()) {
+ case 2:
+ map.set(dcp::Channel::LEFT, 0, 1);
+ map.set(dcp::Channel::RIGHT, 1, 1);
+ break;
+ case 4:
+ map.set(dcp::Channel::LEFT, 0, overall_gain);
+ map.set(dcp::Channel::RIGHT, 1, overall_gain);
+ map.set(dcp::Channel::CENTRE, 0, overall_gain * minus_3dB);
+ map.set(dcp::Channel::CENTRE, 1, overall_gain * minus_3dB);
+ map.set(dcp::Channel::LS, 0, overall_gain);
+ break;
+ case 6:
+ map.set(dcp::Channel::LEFT, 0, overall_gain);
+ map.set(dcp::Channel::RIGHT, 1, overall_gain);
+ map.set(dcp::Channel::CENTRE, 0, overall_gain * minus_3dB);
+ map.set(dcp::Channel::CENTRE, 1, overall_gain * minus_3dB);
+ map.set(dcp::Channel::LS, 0, overall_gain);
+ map.set(dcp::Channel::RS, 1, overall_gain);
+ break;
+ }
+ /* XXX: maybe we should do something better for >6 channel DCPs */
+ return map;
+}
+
+
+AudioMapping
+FFmpegEncoder::many_channel_map() const