From e67884c3b61d6b188e1d8b69d0cd9c39b42afc5e Mon Sep 17 00:00:00 2001 From: Deluan Date: Sat, 7 Feb 2026 10:44:11 -0500 Subject: [PATCH] refactor(transcoding): enhance transcoding config lookup logic for audio codecs Signed-off-by: Deluan --- core/transcode/transcode.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/transcode/transcode.go b/core/transcode/transcode.go index a132f0986..4b5f348a4 100644 --- a/core/transcode/transcode.go +++ b/core/transcode/transcode.go @@ -315,8 +315,17 @@ func (s *deciderService) computeTranscodedStream(ctx context.Context, mf *model. targetFormat = strings.ToLower(profile.AudioCodec) } - // Verify we have a transcoding config for this format + // Verify we have a transcoding config for this format. + // Try the container first, then fall back to the audioCodec (e.g. "ogg" → "opus", "mp4" → "aac"). tc, err := s.ds.Transcoding(ctx).FindByFormat(targetFormat) + if (err != nil || tc == nil) && profile.AudioCodec != "" && !strings.EqualFold(targetFormat, profile.AudioCodec) { + codec := strings.ToLower(profile.AudioCodec) + log.Trace(ctx, "No transcoding config for container, trying audioCodec", "container", targetFormat, "audioCodec", codec) + tc, err = s.ds.Transcoding(ctx).FindByFormat(codec) + if err == nil && tc != nil { + targetFormat = codec + } + } if err != nil || tc == nil { log.Trace(ctx, "Skipping transcoding profile: no transcoding config", "targetFormat", targetFormat) return nil