From 6ea9d791915752e3168a57ae3008559f826b32bd Mon Sep 17 00:00:00 2001 From: Anton Farygin Date: Wed, 25 Nov 2026 23:27:25 +0500 Subject: [PATCH] fix(mod_av): honor the selected video encoder at first frame When the first video frame arrived, mod_av paired an explicitly selected encoder with the container default codec ID. FFmpeg rejects the mismatched context when libvpx is selected for MKV or WebM. Use the selected encoder ID and fall back to the container default only when there is no override. --- src/mod/applications/mod_av/avformat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mod/applications/mod_av/avformat.c b/src/mod/applications/mod_av/avformat.c index f34dd52e5a..1459bb3625 100644 --- a/src/mod/applications/mod_av/avformat.c +++ b/src/mod/applications/mod_av/avformat.c @@ -3395,7 +3395,9 @@ static switch_status_t av_file_write_video(switch_file_handle_t *handle, switch_ context->video_st.width = frame->img->d_w; context->video_st.height = frame->img->d_h; context->video_st.next_pts = switch_time_now() / 1000; - if (add_stream(context, &context->video_st, context->fc, &context->video_codec, context->fc->oformat->video_codec, &handle->mm) == SWITCH_STATUS_SUCCESS && + if (add_stream(context, &context->video_st, context->fc, &context->video_codec, + context->video_codec ? context->video_codec->id : context->fc->oformat->video_codec, + &handle->mm) == SWITCH_STATUS_SUCCESS && open_video(context->fc, context->video_codec, &context->video_st) == SWITCH_STATUS_SUCCESS) { char codec_str[256] = ""; -- 2.50.1