- 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));