]> git.sesse.net Git - nageru/blobdiff - httpd.cpp
Add an option to defs.h to set ffmpeg mux options.
[nageru] / httpd.cpp
index 281bbcf0b05e7e1ebed86403016ff57f7d0eab61..689291e2c7628644f4f4b4ee5aa9c94cb870264d 100644 (file)
--- a/httpd.cpp
+++ b/httpd.cpp
@@ -69,7 +69,7 @@ int HTTPD::answer_to_connection(MHD_Connection *connection,
                                size_t *upload_data_size, void **con_cls)
 {
        printf("url %s\n", url);
-       AVOutputFormat *oformat = av_guess_format("mpegts", nullptr, nullptr);
+       AVOutputFormat *oformat = av_guess_format(STREAM_MUX_NAME, nullptr, nullptr);
        assert(oformat != nullptr);
        HTTPD::Stream *stream = new HTTPD::Stream(oformat, width, height);
        streams.push_back(stream);
@@ -127,7 +127,12 @@ HTTPD::Mux::Mux(AVFormatContext *avctx, int width, int height)
        avstream_audio->codec->channel_layout = AV_CH_LAYOUT_STEREO;
        avstream_audio->codec->time_base = AVRational{1, TIMEBASE};
 
-       if (avformat_write_header(avctx, NULL) < 0) {
+       AVDictionary *options = NULL;
+       vector<pair<string, string>> opts = MUX_OPTS;
+       for (pair<string, string> opt : opts) {
+               av_dict_set(&options, opt.first.c_str(), opt.second.c_str(), 0);
+       }
+       if (avformat_write_header(avctx, &options) < 0) {
                fprintf(stderr, "avformat_write_header() failed\n");
                exit(1);
        }