From 3266868c0a36f74aa71a4022300f766d48a2ee05 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 15 Oct 2022 22:23:08 +0200 Subject: Fix livestreaming: flv does not properly fallback to h264 --- src/main.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index b449666..28c4079 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -861,6 +861,9 @@ static void open_video(AVCodecContext *codec_context, av_dict_set(&options, "tune", "hq", 0); av_dict_set(&options, "rc", "constqp", 0); + if(codec_context->codec_id == AV_CODEC_ID_H264) + av_dict_set(&options, "profile", "high", 0); + ret = avcodec_open2(codec_context, codec_context->codec, &options); if (ret < 0) { fprintf(stderr, "Error: Could not open video codec: %s\n", @@ -1486,6 +1489,12 @@ int main(int argc, char **argv) { } } + //bool use_hevc = strcmp(window_str, "screen") == 0 || strcmp(window_str, "screen-direct") == 0; + if(video_codec != VideoCodec::H264 && strcmp(container_format, "flv") == 0) { + video_codec = VideoCodec::H264; + fprintf(stderr, "Warning: h265 is not compatible with flv, falling back to h264 instead.\n"); + } + const AVCodec *video_codec_f = nullptr; switch(video_codec) { case VideoCodec::H264: @@ -1524,12 +1533,6 @@ int main(int argc, char **argv) { requested_audio_inputs.push_back({ "", "gsr-silent" }); } - //bool use_hevc = strcmp(window_str, "screen") == 0 || strcmp(window_str, "screen-direct") == 0; - if(video_codec != VideoCodec::H264 && strcmp(container_format, "flv") == 0) { - video_codec = VideoCodec::H264; - fprintf(stderr, "Warning: h265 is not compatible with flv, falling back to h264 instead.\n"); - } - AVStream *video_stream = nullptr; std::vector audio_tracks; -- cgit v1.2.3