obs-outputs: Set videocodecid to HEVC/AV1 FourCC in E-RTMP

This commit is contained in:
derrod
2023-07-25 04:12:25 +02:00
committed by Lain
parent ac8ccf4027
commit 38d10934ee
+24 -2
View File
@@ -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));