Skip to content

Commit

Permalink
obs-outputs: Set videocodecid to HEVC/AV1 FourCC in E-RTMP
Browse files Browse the repository at this point in the history
  • Loading branch information
derrod authored and Lain-B committed Jul 26, 2023
1 parent ac8ccf4 commit 38d1093
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions plugins/obs-outputs/flv-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit 38d1093

Please sign in to comment.