[FFmpeg-cvslog] libavformat/hlsenc: fix delete_segments when use_localtime_mkdir
Bela Bodecs
git at videolan.org
Thu Dec 29 06:01:30 EET 2016
ffmpeg | branch: master | Bela Bodecs <bodecsb at vivanet.hu> | Thu Dec 29 12:00:20 2016 +0800| [9ec52a0a9b086d8a916a580ad594c126cd810a45] | committer: Bela Bodecs
libavformat/hlsenc: fix delete_segments when use_localtime_mkdir
When delete_segments hls_flag is specified, deleting old segments may
fail in certain cases when use_localtime_mkdir is in effect and
hls_segment_filename expression contains subdirs. This patch fixes this
behaviour.
Signed-off-by: Bela Bodecs <bodecsb at vivanet.hu>
Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9ec52a0a9b086d8a916a580ad594c126cd810a45
---
libavformat/hlsenc.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cf4d4bd..c9d8e3c 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -194,7 +194,7 @@ static int hls_delete_old_segments(HLSContext *hls) {
}
}
- if (segment) {
+ if (segment && !hls->use_localtime_mkdir) {
if (hls->segment_filename) {
dirname = av_strdup(hls->segment_filename);
} else {
@@ -211,15 +211,20 @@ static int hls_delete_old_segments(HLSContext *hls) {
while (segment) {
av_log(hls, AV_LOG_DEBUG, "deleting old segment %s\n",
segment->filename);
- path_size = strlen(dirname) + strlen(segment->filename) + 1;
+ path_size = (hls->use_localtime_mkdir ? 0 : strlen(dirname)) + strlen(segment->filename) + 1;
path = av_malloc(path_size);
if (!path) {
ret = AVERROR(ENOMEM);
goto fail;
}
- av_strlcpy(path, dirname, path_size);
- av_strlcat(path, segment->filename, path_size);
+ if (hls->use_localtime_mkdir)
+ av_strlcpy(path, segment->filename, path_size);
+ else { // segment->filename contains basename only
+ av_strlcpy(path, dirname, path_size);
+ av_strlcat(path, segment->filename, path_size);
+ }
+
if (unlink(path) < 0) {
av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
path, strerror(errno));
More information about the ffmpeg-cvslog
mailing list