X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=httpd.cpp;h=5900e0ab1425abce934571b8013d4252566d5efc;hb=acc9fe1e6be3e7b1c95f44e45728ec3beae576b0;hp=487d429c5d5b1e49df0a4e019f954823ffb2ceee;hpb=58fce645ca6d76016cc5309ed195bf234e755879;p=nageru diff --git a/httpd.cpp b/httpd.cpp index 487d429..5900e0a 100644 --- a/httpd.cpp +++ b/httpd.cpp @@ -133,7 +133,18 @@ HTTPD::Stream::Stream(AVOutputFormat *oformat, int width, int height, int time_b avctx->flags = AVFMT_FLAG_CUSTOM_IO; - mux.reset(new Mux(avctx, width, height, video_codec, time_base, bit_rate)); + // TODO: This is an ugly place to have this logic. + const string codec_name = global_flags.stream_audio_codec_name.empty() ? + AUDIO_OUTPUT_CODEC_NAME : + global_flags.stream_audio_codec_name; + + AVCodec *codec_audio = avcodec_find_encoder_by_name(codec_name.c_str()); + if (codec_audio == nullptr) { + fprintf(stderr, "ERROR: Could not find codec '%s'\n", codec_name.c_str()); + exit(1); + } + + mux.reset(new Mux(avctx, width, height, video_codec, codec_audio, time_base, bit_rate)); } ssize_t HTTPD::Stream::reader_callback_thunk(void *cls, uint64_t pos, char *buf, size_t max)