Steven Liu <lingjiujia...@gmail.com> 于2018年9月27日周四 下午2:53写道: > > Steven Liu <l...@chinaffmpeg.org> 于2018年9月27日周四 上午6:37写道: > > > > > > > > > On Sep 27, 2018, at 06:10, Michael Niedermayer <mich...@niedermayer.cc> > > > wrote: > > > > > > On Wed, Sep 26, 2018 at 10:07:58AM +0100, James Courtier-Dutton wrote: > > >> On 26 September 2018 at 00:18, Steven Liu <l...@chinaffmpeg.org> wrote: > > >> > > >>> > > >>> > > >>>> On Sep 26, 2018, at 06:49, James Courtier-Dutton > > >>>> <james.dut...@gmail.com> > > >>> wrote: > > >>>> On 25 September 2018 at 23:24, Steven Liu <l...@chinaffmpeg.org> wrote: > > >>> 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); > > >>>> > > >>> > > >>> > > >> Attached patch has the changed error message. > > > > > >> segment.c | 15 +++++++++++++++ > > >> 1 file changed, 15 insertions(+) > > >> a026d4ed5e2ba0505f93a3eece153a567707b812 > > >> 0001-avformat-segment-strftime-date-sub-directories.patch > > >> From 8d8ea7d1f87a77ee23b6681a714da378b5361e4d Mon Sep 17 00:00:00 2001 > > >> From: James Courtier-Dutton <james.dut...@gmail.com> > > >> Date: Wed, 26 Sep 2018 10:05:13 +0100 > > >> Subject: [PATCH] avformat/segment: strftime date sub-directories > > >> > > >> Automatically create sub-directories if needed based on date. > > >> E.g. > > >> ffmpeg ... -timelimit 2147483647 -f segment -strftime 1 -segment_time 10 > > >> "%Y/%m/%d/%Y-%m-%d_%H-%M-%S.mkv" > > >> > > >> Signed-off-by: James Courtier-Dutton <james.dut...@gmail.com> > > >> --- > > >> libavformat/segment.c | 15 +++++++++++++++ > > >> 1 file changed, 15 insertions(+) > > >> > > >> diff --git a/libavformat/segment.c b/libavformat/segment.c > > >> index 7fb4dc7..0e17380 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\n", > > >> dir); > > >> + av_free(fn_copy); > > >> + return AVERROR(errno); > > >> + } > > >> + av_free(fn_copy); > > > > > > How does this interact with urls that are not the file protocol ? > > > > > > I see that this starts out with s->url and then seems to simply treat it > > > as > > > if it was a local file. Its quite possible iam missing something but url > > > != filename > > There will have no error message, and cannot create directory on the HTTP > > server. > > And the same problem is in hlsenc, I think this is a good question, let me > > think about how to fix it. > > Have checked, that should be ok for http: > > MacBook:xxx StevenLiu$ sudo ls > /usr/local/nginx/html/StevenLiu_test/output_dir/Subdir/SubSubdir/ > Password: > ls: /usr/local/nginx/html/StevenLiu_test/output_dir/Subdir/SubSubdir/: > No such file or directory > MacBook:xxx StevenLiu$ sudo ls > /usr/local/nginx/html/StevenLiu_test/output_dir/Subdir/ > ls: /usr/local/nginx/html/StevenLiu_test/output_dir/Subdir/: No such > file or directory > MacBook:xxx StevenLiu$ sudo ls > /usr/local/nginx/html/StevenLiu_test/output_dir/ > ls: /usr/local/nginx/html/StevenLiu_test/output_dir/: No such file or > directory > MacBook:xxx StevenLiu$ sudo ls /usr/local/nginx/html/StevenLiu_test/ > ls: /usr/local/nginx/html/StevenLiu_test/: No such file or directory > MacBook:xxx StevenLiu$ ./ffmpeg -re -i ~/Movies/objectC/facebook.mp4 > -c:v h264_videotoolbox -g 15 -f hls -hls_time 2 -t 10 -method PUT > http://127.0.0.1/StevenLiu_test/output_dir/Subdir/SubSubdir/output_test.m3u8 > ffmpeg version N-92065-g476a77128a Copyright (c) 2000-2018 the FFmpeg > developers > built with Apple LLVM version 9.1.0 (clang-902.0.39.2) > configuration: --enable-libass --enable-opengl --enable-libx264 > --enable-libmp3lame --enable-gpl --enable-nonfree --prefix=/usr/local > --enable-libtesseract --enable-libspeex --enable-libfreetype > --enable-libfontconfig --enable-libfdk-aac --enable-videotoolbox > --enable-libxml2 --enable-librsvg --enable-libtensorflow > libavutil 56. 19.101 / 56. 19.101 > libavcodec 58. 31.101 / 58. 31.101 > libavformat 58. 18.103 / 58. 18.103 > libavdevice 58. 4.104 / 58. 4.104 > libavfilter 7. 33.100 / 7. 33.100 > libswscale 5. 2.100 / 5. 2.100 > libswresample 3. 2.100 / 3. 2.100 > libpostproc 55. 2.100 / 55. 2.100 > Input #0, mov,mp4,m4a,3gp,3g2,mj2, from > '/Users/StevenLiu/Movies/objectC/facebook.mp4': > Metadata: > major_brand : isom > minor_version : 512 > compatible_brands: isomiso2avc1mp41 > encoder : Lavf55.22.102 > description : This File is Created by Easy RealMedia Tools@! > Duration: 02:00:27.85, start: 0.000000, bitrate: 893 kb/s > Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, > 640x480, 797 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default) > Metadata: > handler_name : VideoHandler > Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, > stereo, fltp, 87 kb/s (default) > Metadata: > handler_name : SoundHandler > Stream mapping: > Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_videotoolbox)) > Stream #0:1 -> #0:1 (aac (native) -> aac (native)) > Press [q] to stop, [?] for help > [h264_videotoolbox @ 0x7ff7cf001600] Color range not set for yuv420p. > Using MPEG range. > [hls @ 0x7ff7ce001a00] Opening > 'http://127.0.0.1/StevenLiu_test/output_dir/Subdir/SubSubdir/output_test0.ts' > for writing > Output #0, hls, to > 'http://127.0.0.1/StevenLiu_test/output_dir/Subdir/SubSubdir/output_test.m3u8': > Metadata: > major_brand : isom > minor_version : 512 > compatible_brands: isomiso2avc1mp41 > description : This File is Created by Easy RealMedia Tools@! > encoder : Lavf58.18.103 > Stream #0:0(und): Video: h264 (h264_videotoolbox), yuv420p, > 640x480, q=2-31, 200 kb/s, 25 fps, 90k tbn, 25 tbc (default) > Metadata: > handler_name : VideoHandler > encoder : Lavc58.31.101 h264_videotoolbox > Stream #0:1(und): Audio: aac (LC), 44100 Hz, stereo, fltp, 128 > kb/s (default) > Metadata: > handler_name : SoundHandler > encoder : Lavc58.31.101 aac > [hls @ 0x7ff7ce001a00] Opening > 'http://127.0.0.1/StevenLiu_test/output_dir/Subdir/SubSubdir/output_test1.ts' > for writing > [hls @ 0x7ff7ce001a00] Cannot use rename on non file protocol, this > may lead to races and temporary partial files > [hls @ 0x7ff7ce001a00] Opening > 'http://127.0.0.1/StevenLiu_test/output_dir/Subdir/SubSubdir/output_test2.ts' > for writing > [hls @ 0x7ff7ce001a00] Opening > 'http://127.0.0.1/StevenLiu_test/output_dir/Subdir/SubSubdir/output_test3.ts' > for writing > [hls @ 0x7ff7ce001a00] Opening > 'http://127.0.0.1/StevenLiu_test/output_dir/Subdir/SubSubdir/output_test4.ts' > for writing > frame= 250 fps= 25 q=-0.0 Lsize=N/A time=00:00:10.00 bitrate=N/A speed=0.983x > video:255kB audio:153kB subtitle:0kB other streams:0kB global > headers:0kB muxing overhead: unknown > [aac @ 0x7ff7cf002800] Qavg: 12515.827 > MacBook:xxx StevenLiu$ sudo ls /usr/local/nginx/html/StevenLiu_test/ > output_dir > MacBook:xxx StevenLiu$ sudo ls /usr/local/nginx/html/StevenLiu_test/output_dir > Subdir > MacBook:xxx StevenLiu$ sudo ls > /usr/local/nginx/html/StevenLiu_test/output_dir/Subdir > SubSubdir > MacBook:xxx StevenLiu$ sudo ls > /usr/local/nginx/html/StevenLiu_test/output_dir/Subdir/SubSubdir > output_test.m3u8 output_test0.ts output_test1.ts output_test2.ts > output_test3.ts output_test4.ts > MacBook:xxx StevenLiu$ > > > test http server is nginx, config file context:
#user nobody; worker_processes 1; error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; client_max_body_size 20M; server { listen 80; server_name localhost; location / { root html; dav_methods PUT DELETE MKCOL; create_full_put_path on; dav_access all:rw; index index.html index.htm; } } } > > > > > > > [...] > > > > > > > > > -- > > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > > > > > Modern terrorism, a quick summary: Need oil, start war with country that > > > has oil, kill hundread thousand in war. Let country fall into chaos, > > > be surprised about raise of fundamantalists. Drop more bombs, kill more > > > people, be surprised about them taking revenge and drop even more bombs > > > and strip your own citizens of their rights and freedoms. to be continued > > > _______________________________________________ > > > ffmpeg-devel mailing list > > > ffmpeg-devel@ffmpeg.org > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > Thanks > > Steven > > > > > > > > > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel