type = AVIO_DATA_MARKER_SYNC_POINT;
}
+ HTTPD::StreamID stream_id{ HTTPD::MAIN_STREAM, 0 };
if (type == AVIO_DATA_MARKER_HEADER) {
stream_mux_header.append((char *)buf, buf_size);
- httpd->set_header(HTTPD::MAIN_STREAM, stream_mux_header);
+ httpd->set_header(stream_id, stream_mux_header);
} else {
- httpd->add_data(HTTPD::MAIN_STREAM, (char *)buf, buf_size, type == AVIO_DATA_MARKER_SYNC_POINT, time, AVRational{ AV_TIME_BASE, 1 });
+ httpd->add_data(stream_id, (char *)buf, buf_size, type == AVIO_DATA_MARKER_SYNC_POINT, time, AVRational{ AV_TIME_BASE, 1 });
}
return buf_size;
}
string video_extradata = x264_encoder->get_global_headers();
+ // If audio is disabled (ie., we won't ever see any audio packets),
+ // set nullptr here to also not include the stream in the mux.
+ AVCodecParameters *audio_codecpar =
+ global_flags.enable_audio ? audio_encoder->get_codec_parameters().release() : nullptr;
+
unique_ptr<Mux> mux;
- mux.reset(new Mux(avctx, global_flags.width, global_flags.height, Mux::CODEC_H264, video_extradata, audio_encoder->get_codec_parameters().get(),
+ mux.reset(new Mux(avctx, global_flags.width, global_flags.height, Mux::CODEC_H264, video_extradata, audio_codecpar,
get_color_space(global_flags.ycbcr_rec709_coefficients), COARSE_TIMEBASE,
/*write_callback=*/nullptr, Mux::WRITE_FOREGROUND, { &stream_mux_metrics }));
stream_mux_metrics.init({{ "destination", "http" }});
parse_flags(PROGRAM_KAERU, argc, argv);
if (optind + 1 != argc) {
usage(PROGRAM_KAERU);
- exit(1);
+ abort();
}
- global_flags.num_cards = 1; // For latency metrics.
+ global_flags.max_num_cards = 1; // For latency metrics.
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(58, 9, 100)
av_register_all();
FFmpegCapture video(argv[optind], global_flags.width, global_flags.height);
video.set_pixel_format(FFmpegCapture::PixelFormat_NV12);
video.set_frame_callback(bind(video_frame_callback, &video, x264_encoder.get(), audio_encoder.get(), _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11));
- if (!global_flags.transcode_audio) {
+ if (!global_flags.transcode_audio && global_flags.enable_audio) {
video.set_audio_callback(bind(audio_frame_callback, http_mux.get(), _1, _2));
}
video.configure_card();