From 2ec81249de2e459e6a6c0f625040ecd5a39f77dd Mon Sep 17 00:00:00 2001 From: Keukhan Date: Tue, 12 Nov 2024 22:25:20 +0900 Subject: [PATCH] Added profile settings for x264 --- .../codec/encoder/encoder_avc_x264.cpp | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/projects/transcoder/codec/encoder/encoder_avc_x264.cpp b/src/projects/transcoder/codec/encoder/encoder_avc_x264.cpp index e2a241496..2ea9f7ed2 100644 --- a/src/projects/transcoder/codec/encoder/encoder_avc_x264.cpp +++ b/src/projects/transcoder/codec/encoder/encoder_avc_x264.cpp @@ -54,6 +54,33 @@ bool EncoderAVCx264::SetCodecParams() // >1 => Set _codec_context->thread_count = GetRefTrack()->GetThreadCount() < 0 ? FFMIN(FFMAX(4, av_cpu_count() / 3), 8) : GetRefTrack()->GetThreadCount(); + // Profile + auto profile = GetRefTrack()->GetProfile(); + if (profile.IsEmpty() == true) + { + ::av_opt_set(_codec_context->priv_data, "profile", "baseline", 0); + } + else + { + if (profile == "baseline") + { + ::av_opt_set(_codec_context->priv_data, "profile", "baseline", 0); + } + else if (profile == "main") + { + ::av_opt_set(_codec_context->priv_data, "profile", "main", 0); + } + else if (profile == "high") + { + ::av_opt_set(_codec_context->priv_data, "profile", "high", 0); + } + else + { + logtw("This is an unknown profile. change to the default(baseline) profile."); + ::av_opt_set(_codec_context->priv_data, "profile", "baseline", 0); + } + } + // Preset if (GetRefTrack()->GetPreset() == "slower") { @@ -81,9 +108,6 @@ bool EncoderAVCx264::SetCodecParams() ::av_opt_set(_codec_context->priv_data, "preset", "faster", 0); } - // Profile - ::av_opt_set(_codec_context->priv_data, "profile", "main", 0); - // Tune ::av_opt_set(_codec_context->priv_data, "tune", "zerolatency", 0);