From d98d2e0f2ea49878101fec7a5b5598e14af082ae Mon Sep 17 00:00:00 2001 From: sladro Date: Tue, 16 Dec 2025 16:54:18 +0800 Subject: [PATCH] update plugins/publish/publish_node.cpp --- plugins/publish/publish_node.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/publish/publish_node.cpp b/plugins/publish/publish_node.cpp index 9f29ffe..68d8e36 100644 --- a/plugins/publish/publish_node.cpp +++ b/plugins/publish/publish_node.cpp @@ -96,10 +96,15 @@ public: av_dict_set(&opts, "hls_time", seg.c_str(), 0); av_dict_set(&opts, "hls_list_size", "0", 0); av_dict_set(&opts, "hls_flags", "delete_segments+append_list", 0); + // Ensure HLS output directory exists (HLS muxer uses AVFMT_NOFILE) + std::filesystem::path p(url_); + if (!p.has_extension()) p /= "index.m3u8"; + std::error_code ec; + std::filesystem::create_directories(p.parent_path(), ec); } - // For RTSP server, let libavformat handle the listening socket in write_header. - if (proto_ == "hls" && !(fmt_->oformat->flags & AVFMT_NOFILE)) { + // For non-NOFILE formats, open IO context manually. + if (!(fmt_->oformat->flags & AVFMT_NOFILE)) { if (av_io_open(url_, opts) < 0) { av_dict_free(&opts); Close();