From 9e6b8e6cfc58fafbcd71896a7d0f9b5e07733f18 Mon Sep 17 00:00:00 2001 From: Anton Farygin Date: Wed, 25 Nov 2026 23:32:02 +0500 Subject: [PATCH] fix(mod_vlc): attach MP4 recording output to the media --- src/mod/formats/mod_vlc/mod_vlc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mod/formats/mod_vlc/mod_vlc.c b/src/mod/formats/mod_vlc/mod_vlc.c index 6b725515f4..f0d9d3f961 100644 --- a/src/mod/formats/mod_vlc/mod_vlc.c +++ b/src/mod/formats/mod_vlc/mod_vlc.c @@ -590,7 +590,7 @@ static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image const char *tmp; vlc_file_context_t *acontext = handle->private_info; const char * opts[25] = {0}; - int argc = 2; + int argc = 1; vlc_video_context_t *vcontext; if (!acontext) { @@ -598,7 +598,6 @@ static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image } opts[0] = *vlc_args; - opts[1] = switch_core_sprintf(acontext->pool, "--sout=%s", acontext->path); pool = acontext->pool; @@ -665,14 +664,15 @@ static switch_status_t av_init_handle(switch_file_handle_t *handle, switch_image vcontext->samplerate, vcontext->channels); vcontext->m = libvlc_media_new_location(acontext->vlc_handle, imem_main); - - libvlc_media_add_option_flag( vcontext->m, imem_slave, libvlc_media_option_trusted ); - if (vcontext->m == NULL) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "VLC error opening %s for writing\n", acontext->path); return SWITCH_STATUS_FALSE; } + /* Attach the recording output to the input, not the VLC instance. */ + libvlc_media_add_option_flag(vcontext->m, switch_core_sprintf(pool, ":sout=%s", acontext->path), libvlc_media_option_trusted); + libvlc_media_add_option_flag(vcontext->m, imem_slave, libvlc_media_option_trusted); + vcontext->mp = libvlc_media_player_new_from_media(vcontext->m); vcontext->samples = 0; @@ -780,7 +780,7 @@ static switch_status_t vlc_file_open(switch_file_handle_t *handle, const char *p if (switch_test_flag(handle, SWITCH_FILE_FLAG_VIDEO) && switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) { if ((ext = strrchr(path, '.')) && !strcasecmp(ext, ".mp4")) { realpath = path; - path = switch_core_sprintf(context->pool, "#transcode{vcodec=h264,acodec=mpga}:std{access=file,mux=mp4,dst=%s}", path); + path = switch_core_sprintf(context->pool, "#transcode{vcodec=h264,acodec=mp4a}:std{access=file,mux=mp4,dst=%s}", path); } else if (handle->stream_name && (!strcasecmp(handle->stream_name, "rtmp") || !strcasecmp(handle->stream_name, "youtube"))) { handle->mm.samplerate = 44100; -- 2.50.1