]> git.sesse.net Git - nageru/blobdiff - mux.cpp
More fixes for non-PCM HTTP audio codecs.
[nageru] / mux.cpp
diff --git a/mux.cpp b/mux.cpp
index 82d42abe705c75e2af79259252a68e5494e6763f..addd24c7c8c739ced966f5ad51dba0b6d98c7fca 100644 (file)
--- a/mux.cpp
+++ b/mux.cpp
@@ -9,7 +9,7 @@
 
 using namespace std;
 
-Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, int time_base)
+Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, const AVCodec *codec_audio, int time_base, int bit_rate)
        : avctx(avctx)
 {
        AVCodec *codec_video = avcodec_find_encoder((video_codec == CODEC_H264) ? AV_CODEC_ID_H264 : AV_CODEC_ID_RAWVIDEO);
@@ -46,18 +46,13 @@ Mux::Mux(AVFormatContext *avctx, int width, int height, Codec video_codec, int t
                avstream_video->codec->flags = AV_CODEC_FLAG_GLOBAL_HEADER;
        }
 
-       AVCodec *codec_audio = avcodec_find_encoder_by_name(AUDIO_OUTPUT_CODEC_NAME);
-       if (codec_audio == nullptr) {
-               fprintf(stderr, "ERROR: Could not find codec '%s'\n", AUDIO_OUTPUT_CODEC_NAME);
-               exit(1);
-       }
        avstream_audio = avformat_new_stream(avctx, codec_audio);
        if (avstream_audio == nullptr) {
                fprintf(stderr, "avformat_new_stream() failed\n");
                exit(1);
        }
        avstream_audio->time_base = AVRational{1, time_base};
-       avstream_audio->codec->bit_rate = AUDIO_OUTPUT_BIT_RATE;
+       avstream_audio->codec->bit_rate = bit_rate;
        avstream_audio->codec->sample_rate = OUTPUT_FREQUENCY;
        avstream_audio->codec->channels = 2;
        avstream_audio->codec->channel_layout = AV_CH_LAYOUT_STEREO;