From 38d10934ee5bc7252c27df0943d63acf78f4ee82 Mon Sep 17 00:00:00 2001 From: derrod Date: Tue, 25 Jul 2023 04:12:25 +0200 Subject: [PATCH] obs-outputs: Set videocodecid to HEVC/AV1 FourCC in E-RTMP --- plugins/obs-outputs/flv-mux.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/obs-outputs/flv-mux.c b/plugins/obs-outputs/flv-mux.c index bc2eb5209..38e81bd8c 100644 --- a/plugins/obs-outputs/flv-mux.c +++ b/plugins/obs-outputs/flv-mux.c @@ -29,7 +29,6 @@ //#define DEBUG_TIMESTAMPS //#define WRITE_FLV_HEADER -#define VIDEODATA_AVCVIDEOPACKET 7.0 #define AUDIODATA_AAC 10.0 #define VIDEO_FRAMETYPE_OFFSET 4 @@ -101,6 +100,29 @@ static inline double encoder_bitrate(obs_encoder_t *encoder) return bitrate; } +static const double VIDEODATA_AVCVIDEOPACKET = 7.0; +// Additional FLV onMetaData values for Enhanced RTMP/FLV +static const double VIDEODATA_AV1VIDEOPACKET = 1635135537.0; // FourCC "av01" +#ifdef ENABLE_HEVC +static const double VIDEODATA_HEVCVIDEOPACKET = 1752589105.0; // FourCC "hvc1" +#endif + +static inline double encoder_video_codec(obs_encoder_t *encoder) +{ + const char *codec = obs_encoder_get_codec(encoder); + + if (strcmp(codec, "h264") == 0) + return VIDEODATA_AVCVIDEOPACKET; + if (strcmp(codec, "av1") == 0) + return VIDEODATA_AV1VIDEOPACKET; +#ifdef ENABLE_HEVC + if (strcmp(codec, "hevc") == 0) + return VIDEODATA_HEVCVIDEOPACKET; +#endif + + return 0.0; +} + #define FLV_INFO_SIZE_OFFSET 42 void write_file_info(FILE *file, int64_t duration_ms, int64_t size) @@ -143,7 +165,7 @@ static void build_flv_meta_data(obs_output_t *context, uint8_t **output, enc_num_val(&enc, end, "height", (double)obs_encoder_get_height(vencoder)); - enc_num_val(&enc, end, "videocodecid", VIDEODATA_AVCVIDEOPACKET); + enc_num_val(&enc, end, "videocodecid", encoder_video_codec(vencoder)); enc_num_val(&enc, end, "videodatarate", encoder_bitrate(vencoder)); enc_num_val(&enc, end, "framerate", video_output_get_frame_rate(video));