Allow opus audio codec with mpegts container

The TODO comment next to the opus fallback noted this case was
unhandled. ffmpeg's mpegts muxer does support opus (DVB private-stream
0x06 with "Opus" registration descriptor) and demuxes it back fine,
verified with a live h264+opus mpegts mux/demux roundtrip. Without
this, anyone publishing to MediaMTX/SRT (or any other mpegts sink that
benefits from opus's lower latency vs aac) gets silently downgraded to
aac, which then can't be carried over WebRTC on the playback side.

Treat ".ts" the same as mp4/mkv/webm in select_audio_codec_with_fallback
so -ac opus is honoured when the container is mpegts.
This commit is contained in:
endigma
2026-05-04 19:13:43 +01:00
committed by dec05eba
parent 4e84f0e49d
commit 5e694a633b

View File

@@ -3018,11 +3018,10 @@ static gsr_audio_codec select_audio_codec_with_fallback(gsr_audio_codec audio_co
break; break;
} }
case GSR_AUDIO_CODEC_OPUS: { case GSR_AUDIO_CODEC_OPUS: {
// TODO: Also check mpegts? if(file_extension != "mp4" && file_extension != "mkv" && file_extension != "webm" && file_extension != "ts") {
if(file_extension != "mp4" && file_extension != "mkv" && file_extension != "webm") {
//audio_codec_to_use = "aac"; //audio_codec_to_use = "aac";
audio_codec = GSR_AUDIO_CODEC_AAC; audio_codec = GSR_AUDIO_CODEC_AAC;
fprintf(stderr, "gsr warning: opus audio codec is only supported by .mp4, .mkv and .webm files, falling back to aac instead\n"); fprintf(stderr, "gsr warning: opus audio codec is only supported by .mp4, .mkv, .webm and .ts files, falling back to aac instead\n");
} }
break; break;
} }