[FFmpeg-devel] [PATCH 1/3] avformat/hlsenc: support mkdir_p for use_localtime_mkdir
Michael Niedermayer
michael at niedermayer.cc
Tue Sep 27 01:50:14 EEST 2016
On Mon, Sep 26, 2016 at 04:04:32PM +0800, Steven Liu wrote:
>
> hlsenc.c | 31 ++++++++++++++++++++++++++++++-
> 1 file changed, 30 insertions(+), 1 deletion(-)
> 8647c63d575b475e6e19b6427061787e39081bc4 0001-avformat-hlsenc-support-mkdir_p-for-use_localtime_mk.patch
> From 4897d06fc1c9c4d9d302942b6e3ac8a8e25aa793 Mon Sep 17 00:00:00 2001
> From: Steven Liu <lingjiujianke at gmail.com>
> Date: Mon, 26 Sep 2016 13:50:31 +0800
> Subject: [PATCH 1/3] avformat/hlsenc: support mkdir_p for use_localtime_mkdir
>
> when use use_localtime_mkdir to create multi level dir,
> ffmpeg give error message:
> ffmpeg -i ~/Movies/objectC/facebook.mp4 -c copy -use_localtime 1
> -use_localtime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d/%s.ts'
> out.m3u8
> error message:
> Could not create directory 20160926/file-20160926 with use_localtime_mkdir
> add mkdir_p for support the multi level dir
>
> Signed-off-by: Steven Liu <lingjiujianke at gmail.com>
> ---
> libavformat/hlsenc.c | 31 ++++++++++++++++++++++++++++++-
> 1 file changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 428bae4..ac79759 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -133,6 +133,35 @@ typedef struct HLSContext {
> double initial_prog_date_time;
> } HLSContext;
>
> +static int mkdir_p(const char *path) {
> + char *temp = strdup(path);
mixing malloc() based functions and av_malloc() is not safe
av_strdup()
> + char *pos = temp;
> +
> + if (!path) {
> + return -1;
> + }
> +
> + if (!strncmp(temp, "/", 1)) {
missing allocation failure check
> + pos++;
> + } else if (!strncmp(temp, "./", 2)) {
> + pos += 2;
> + }
> + for ( ; *pos != '\0'; ++pos) {
> + if (*pos == '/') {
> + *pos = '\0';
> + mkdir(temp, 0755);
> + *pos = '/';
> + }
> + }
> +
> + if (*(pos - 1) != '/') {
all the '/' stuff looks non portable (windows)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160927/73468253/attachment.sig>
More information about the ffmpeg-devel
mailing list