diff --git a/src/host.cpp b/src/host.cpp index 12d26db8b..e5766c618 100644 --- a/src/host.cpp +++ b/src/host.cpp @@ -343,6 +343,7 @@ void print_capabilities(struct module *root, bool use_vidcap) cout << ", "; cout << "{\"name\":\"" << c.name << "\", " + "\"priority\": " << c.priority << ", " "\"encoders\":["; int z = 0; diff --git a/src/video_compress.h b/src/video_compress.h index d957135fb..61efe2024 100644 --- a/src/video_compress.h +++ b/src/video_compress.h @@ -197,6 +197,7 @@ struct encoder{ struct codec{ std::string name; std::vector encoders; + int priority; }; struct compress_module_info{ diff --git a/src/video_compress/cineform.cpp b/src/video_compress/cineform.cpp index e893beb2c..b238ea1aa 100644 --- a/src/video_compress/cineform.cpp +++ b/src/video_compress/cineform.cpp @@ -596,6 +596,7 @@ static compress_module_info get_cineform_module_info(){ codec codec_info; codec_info.name = "Cineform"; + codec_info.priority = 400; codec_info.encoders.emplace_back(encoder{"default", ""}); module_info.codecs.emplace_back(std::move(codec_info)); diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index 595b151e5..83cfa7e30 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -118,6 +118,7 @@ typedef struct { double avg_bpp; string (*get_preset)(string const & enc_name, int width, int height, double fps); void (*set_param)(AVCodecContext *, struct setparam_param *); + int capabilities_priority; } codec_params_t; static string get_h264_h265_preset(string const & enc_name, int width, int height, double fps); @@ -144,55 +145,64 @@ static unordered_map> codec_params = { * 2, // take into consideration that our H.264 is less effective due to specific preset/tune // note - not used for libx264, which uses CRF by default get_h264_h265_preset, - setparam_h264_h265_av1 + setparam_h264_h265_av1, + 100 }}, { H265, codec_params_t{ [](bool) { return "libx265"; }, 0.04 * 2 * 2, // note - not used for libx265, which uses CRF by default get_h264_h265_preset, - setparam_h264_h265_av1 + setparam_h264_h265_av1, + 101 }}, { MJPG, codec_params_t{ nullptr, 1.2, nullptr, - setparam_jpeg + setparam_jpeg, + 102 }}, { J2K, codec_params_t{ nullptr, 1.0, nullptr, - setparam_default + setparam_default, + 500 }}, { VP8, codec_params_t{ nullptr, 0.4, nullptr, - setparam_vp8_vp9 + setparam_vp8_vp9, + 103 }}, { VP9, codec_params_t{ nullptr, 0.4, nullptr, setparam_vp8_vp9, + 104 }}, { HFYU, codec_params_t{ nullptr, 0, nullptr, - setparam_default + setparam_default, + 501 }}, { FFV1, codec_params_t{ nullptr, 0, nullptr, - setparam_default + setparam_default, + 502 }}, { AV1, codec_params_t{ nullptr, 0, nullptr, - setparam_h264_h265_av1 + setparam_h264_h265_av1, + 600 }}, }; @@ -527,6 +537,7 @@ static compress_module_info get_libavcodec_module_info(){ codec codec_info; codec_info.name = get_codec_name(param.first); + codec_info.priority = param.second.capabilities_priority; codec_info.encoders.emplace_back( encoder{"default", ":codec=" + codec_info.name});