/// <summary>
        /// Initializes a new instance of the <see cref="AudioOutputStream"/> class.
        /// </summary>
        /// <param name="stream">The audio stream.</param>
        /// <param name="config">The stream setting.</param>
        internal AudioOutputStream(OutputStream <AudioFrame> stream, AudioEncoderSettings config)
        {
            this.stream = stream;

            long channelLayout = ffmpeg.av_get_default_channel_layout(config.Channels);

            swrContext = ffmpeg.swr_alloc_set_opts(
                null,
                channelLayout,
                (AVSampleFormat)config.SampleFormat,
                config.SampleRate,
                channelLayout,
                (AVSampleFormat)SampleFormat.SingleP,
                config.SampleRate,
                0,
                null);

            ffmpeg.swr_init(swrContext);

            Configuration = config;
            frame         = AudioFrame.Create(config.SampleRate, config.Channels, config.SamplesPerFrame, channelLayout, SampleFormat.SingleP);
        }
Beispiel #2
0
 /// <summary>
 /// Adds a new audio stream to the file.
 /// </summary>
 /// <param name="settings">The video stream settings.</param>
 /// <returns>This <see cref="MediaBuilder"/> object.</returns>
 public MediaBuilder WithAudio(AudioEncoderSettings settings)
 {
     container.AddAudioStream(settings);
     return(this);
 }