@@ -52,7 +52,7 @@ class FFmpegAudioCodec: FFmpegCodec {
5252 ///
5353 /// Describes the number and physical / spatial arrangement of the channels. (e.g. "5.1 surround" or "stereo")
5454 ///
55- var channelLayout : Int64 = 0
55+ var channelLayout : AVChannelLayout = . init ( )
5656
5757 ///
5858 /// Instantiates an AudioCodec object, given a pointer to its parameters.
@@ -63,12 +63,13 @@ class FFmpegAudioCodec: FFmpegCodec {
6363
6464 try super. init ( fromParameters: paramsPointer)
6565
66- self . sampleFormat = FFmpegSampleFormat ( encapsulating: context. sample_fmt)
67- self . channelCount = params. channels
68-
6966 // Correct channel layout if necessary.
7067 // NOTE - This is necessary for some files like WAV files that don't specify a channel layout.
71- self . channelLayout = context. channel_layout != 0 ? Int64 ( context. channel_layout) : av_get_default_channel_layout ( context. channels)
68+ // self.channelLayout = context.channel_layout != 0 ? Int64(context.channel_layout) : av_get_default_channel_layout(context.channels)
69+ self . channelLayout = context. ch_layout
70+
71+ self . sampleFormat = FFmpegSampleFormat ( encapsulating: context. sample_fmt)
72+ self . channelCount = params. ch_layout. nb_channels
7273
7374 // Use multithreading to speed up decoding.
7475 self . contextPointer. pointee. thread_count = Self . threadCount
@@ -83,7 +84,8 @@ class FFmpegAudioCodec: FFmpegCodec {
8384 // Some streams may contain the wrong header information. So, recompute these
8485 // values after opening the codec.
8586
86- self . channelLayout = context. channel_layout != 0 ? Int64 ( context. channel_layout) : av_get_default_channel_layout ( context. channels)
87+ // self.channelLayout = context.channel_layout != 0 ? Int64(context.channel_layout) : av_get_default_channel_layout(context.channels)
88+ self . channelLayout = context. ch_layout
8789 self . sampleFormat = FFmpegSampleFormat ( encapsulating: context. sample_fmt)
8890 }
8991
0 commit comments