From 3b62445aabcc7fca1c5f33bc5452b1658611463e Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 15 Mar 2023 02:18:06 +0100 Subject: [PATCH 1/2] ffmpeg-mux: Set experimental compliance for FFmpeg < 6.0 With 5fe417bce1f0c34daa573edbafd46667f5c9f06c it became possible to use Opus in local recordings, this could potentially have the user try to record Opus in MP4. FLAC in MP4 was marked as stable in FFmpeg 6.0 Opus in MP4 was marked as stable in FFmpeg 4.3 For Ubuntu 20.04 we still need the latter, for 22.04 (and potentially other Linux distributions) the former. While FLAC is not yet implemented, we may want to do that in the near future so for simplicity just keep it at 6.0. --- plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c index a2287a66dc533b..d6ba35013871cb 100644 --- a/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c +++ b/plugins/obs-ffmpeg/ffmpeg-mux/ffmpeg-mux.c @@ -1051,6 +1051,11 @@ static int ffmpeg_mux_init_context(struct ffmpeg_mux *ffm) ffm->output->oformat->audio_codec = AV_CODEC_ID_NONE; #endif +#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(60, 0, 100) + /* Allow FLAC/OPUS in MP4 */ + ffm->output->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; +#endif + if (!init_streams(ffm)) { free_avformat(ffm); return FFM_ERROR; From fae688bccce61be64da2561af93037c914053940 Mon Sep 17 00:00:00 2001 From: derrod Date: Wed, 15 Mar 2023 02:26:41 +0100 Subject: [PATCH 2/2] obs-ffmpeg: Pass correct audio codec to muxer subprocess --- plugins/obs-ffmpeg/obs-ffmpeg-mux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mux.c b/plugins/obs-ffmpeg/obs-ffmpeg-mux.c index b821ada05d8081..1a3ce9cb402c60 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-mux.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-mux.c @@ -313,7 +313,9 @@ static void build_command_line(struct ffmpeg_muxer *stream, struct dstr *cmd, add_video_encoder_params(stream, cmd, vencoder); if (num_tracks) { - dstr_cat(cmd, "aac "); + const char *codec = obs_encoder_get_codec(aencoders[0]); + dstr_cat(cmd, codec); + dstr_cat(cmd, " "); for (int i = 0; i < num_tracks; i++) { add_audio_encoder_params(cmd, aencoders[i]);