Bump ffmpeg to 5.1.2 "Riemann"
[dcpomatic.git] / src / lib / ffmpeg_file_encoder.cc
index 7d89b7bd00ce4e7a7fc2027a2bff4bdba2f20ac1..d7833265d630d130437a5a3bedee49ac6f63f221 100644 (file)
@@ -73,8 +73,7 @@ public:
                _codec_context->bit_rate = channels * 128 * 1024;
                _codec_context->sample_fmt = sample_format;
                _codec_context->sample_rate = frame_rate;
-               _codec_context->channel_layout = av_get_default_channel_layout (channels);
-               _codec_context->channels = channels;
+               av_channel_layout_default(&_codec_context->ch_layout, channels);
 
                int r = avcodec_open2 (_codec_context, _codec, 0);
                if (r < 0) {
@@ -143,7 +142,7 @@ public:
 
                frame->nb_samples = size;
                frame->format = _codec_context->sample_fmt;
-               frame->channels = channels;
+               frame->ch_layout.nb_channels = channels;
                int r = avcodec_fill_audio_frame (frame, channels, _codec_context->sample_fmt, (const uint8_t *) samples, buffer_size, 0);
                DCPOMATIC_ASSERT (r >= 0);
 
@@ -396,7 +395,9 @@ FFmpegFileEncoder::flush ()
        }
 
        auto const r = av_write_trailer(_format_context);
-       DCPOMATIC_ASSERT(r == 0);
+       if (r) {
+               throw EncodeError(N_("av_write_trailer"), N_("FFmpegFileEncoder::flush"), r);
+       }
 }