Message ID | 183EFA33-3FB5-4D82-9F2B-9EF806874795@chinaffmpeg.org |
---|---|
State | New |
Headers | show |
> On Sep 26, 2018, at 06:49, James Courtier-Dutton <james.dutton@gmail.com> wrote: > > > > On 25 September 2018 at 23:24, Steven Liu <lq@chinaffmpeg.org> wrote: > @@ -200,12 +200,27 @@ static int set_segment_filename(AVFormatContext *s) > if (seg->use_strftime) { > time_t now0; > struct tm *tm, tmpbuf; > + const char *dir; > + char *fn_copy; > time(&now0); > tm = localtime_r(&now0, &tmpbuf); > ==========^^^ This is the time it uses. No command like option. of course i know this line. > if (!strftime(buf, sizeof(buf), s->url, tm)) { > av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n"); > return AVERROR(EINVAL); > } > + /* Automatically create directories if needed */ > + /* E.g. %Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv */ > + fn_copy = av_strdup(buf); > + if (!fn_copy) { > + return AVERROR(ENOMEM); > + } > + dir = av_dirname(fn_copy); > + if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { > + av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir); > ==========look at here, what dose this error message mean? I just think this error message is not a good message, because there have no use_localtime_mkdir for libavformat/segment.c > > That is saying that the ff_mkdir_p call failed. > If the error message is confusing, we can change it to: yes, the error message is confusing, maybe change it here is better. > > + av_log(oc, AV_LOG_ERROR, "Could not create directory %s\n", dir); > Thanks Steven
diff --git a/libavformat/segment.c b/libavformat/segment.c index 7fb4dc7..57fce8d 100644 --- a/libavformat/segment.c +++ b/libavformat/segment.c @@ -200,12 +200,27 @@ static int set_segment_filename(AVFormatContext *s) if (seg->use_strftime) { time_t now0; struct tm *tm, tmpbuf; + const char *dir; + char *fn_copy; time(&now0); tm = localtime_r(&now0, &tmpbuf); if (!strftime(buf, sizeof(buf), s->url, tm)) { av_log(oc, AV_LOG_ERROR, "Could not get segment filename with strftime\n"); return AVERROR(EINVAL); } + /* Automatically create directories if needed */ + /* E.g. %Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv */ + fn_copy = av_strdup(buf); + if (!fn_copy) { + return AVERROR(ENOMEM); + } + dir = av_dirname(fn_copy); + if (ff_mkdir_p(dir) == -1 && errno != EEXIST) { + av_log(oc, AV_LOG_ERROR, "Could not create directory %s with use_localtime_mkdir\n", dir); ==========look at here, what dose this error message mean? + av_free(fn_copy); + return AVERROR(errno);