PR #25749 opened by Kilian (lusoris) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25749 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/25749.patch
With `-single_file 1`, segment records carry an empty file name because every segment goes into one file. Trimming the window then asks `dashenc_delete_segment_file()` to delete the directory name plus an empty name, which is the output directory itself: on a local file system the delete fails with "Directory not empty", over HTTP it sends a DELETE for the directory URL. This was noted as a pre-existing issue in the review of #25735. The fix skips per-segment deletion in single-file mode and makes `dashenc_delete_segment_file()` ignore an empty name. Tested on master 2546b6f061fe: - Before: `-single_file 1 -window_size 1 -extra_window_size 0 -seg_duration 1` on a 6 s source logs five "failed to delete .../: Directory not empty" errors. - After: no delete errors; the MPD and the single media file stay in place. - Multi-file control run: old segments are still removed as before. - `make fate-dash-mpd-timing fate-source` passes; `tools/patcheck` reports only the changelog hint. >From 4cef47d9df8842cde6c2fdd482562eaa584cb589 Mon Sep 17 00:00:00 2001 From: lusoris <[email protected]> Date: Wed, 4 Nov 2026 09:19:46 +0100 Subject: [PATCH] avformat/dashenc: do not delete output dir in single-file trimming In single-file mode (-single_file 1), segment records store an empty filename because all media segments are written into the shared single file. When the segment window is trimmed, dashenc_delete_media_segments() called dashenc_delete_segment_file() with the empty segment filename, which resulted in attempting to delete c->dirname (the output directory) and produced errors like 'failed to delete ...: Directory not empty'. Fix this by skipping file deletion in dashenc_delete_media_segments() when single_file is enabled so that trimming only drops the in-memory segment records, and guard dashenc_delete_segment_file() against empty filenames. Signed-off-by: lusoris <[email protected]> --- libavformat/dashenc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index 36f39bd083a..a5d5fc42a6b 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -1744,6 +1744,9 @@ static int dashenc_delete_segment_file(AVFormatContext *s, const char* file) DASHContext *c = s->priv_data; AVBPrint buf; + if (!file || !file[0]) + return 0; + av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); av_bprintf(&buf, "%s%s", c->dirname, file); @@ -1761,8 +1764,11 @@ static int dashenc_delete_segment_file(AVFormatContext *s, const char* file) static inline void dashenc_delete_media_segments(AVFormatContext *s, OutputStream *os, int remove_count) { + DASHContext *c = s->priv_data; + for (int i = 0; i < remove_count; ++i) { - dashenc_delete_segment_file(s, os->segments[i]->file); + if (!c->single_file) + dashenc_delete_segment_file(s, os->segments[i]->file); // Delete the segment regardless of whether the file was successfully deleted av_free(os->segments[i]); -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
