From 5ce7971296e1bda924f04035e47b8d55a6fda6aa Mon Sep 17 00:00:00 2001 From: bin Date: Thu, 16 Feb 2023 15:35:10 +0800 Subject: [PATCH] libobs/media-io: Specify codec tag when it is compatible in out stream --- libobs/media-io/media-remux.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libobs/media-io/media-remux.c b/libobs/media-io/media-remux.c index dd060a4f2a1005..5ec50266955401 100644 --- a/libobs/media-io/media-remux.c +++ b/libobs/media-io/media-remux.c @@ -153,17 +153,21 @@ static inline bool init_output(media_remux_job_t job, const char *out_filename) av_dict_copy(&out_stream->metadata, in_stream->metadata, 0); #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 48, 101) - if (in_stream->codecpar->codec_id == AV_CODEC_ID_HEVC && - job->ofmt_ctx->oformat->codec_tag && + if(!job->ofmt_ctx->oformat->codec_tag) { + out_stream->codecpar->codec_tag = 0; + }else if(in_stream->codecpar->codec_id == AV_CODEC_ID_HEVC && av_codec_get_id(job->ofmt_ctx->oformat->codec_tag, - MKTAG('h', 'v', 'c', '1')) == - out_stream->codecpar->codec_id) { + MKTAG('h', 'v', 'c', '1')) { // Tag HEVC files with industry standard HVC1 tag for wider device compatibility // when HVC1 tag is supported by out stream codec out_stream->codecpar->codec_tag = MKTAG('h', 'v', 'c', '1'); - } else { - // Otherwise tag 0 to let FFmpeg automatically select the appropriate tag + }else if(av_codec_get_id(job->ofmt_ctx->oformat->codec_tag, + in_stream->codecpar->codec_tag) == + out_stream->codecpar->codec_id) { + // Specify codec_tag when the tag is valid in out stream codec + out_stream->codecpar->codec_tag = in_stream->codecpar->codec_tag; + }else{ out_stream->codecpar->codec_tag = 0; } #else