diff options
author | Steven Liu <lingjiujianke@gmail.com> | 2016-09-26 10:51:02 +0300 |
---|---|---|
committer | Steven Liu <lingjiujianke@gmail.com> | 2016-10-04 01:41:53 +0300 |
commit | be1d32492e58cbba6d69d3ce67545536b15e051d (patch) | |
tree | fe62ecf8063771c3b5e6fe4e2ce0e02df9df3e50 /libavformat | |
parent | d0be0cbebc207f3a39da2a668f45be413c9152c4 (diff) |
avformat/hlsenc: support multi level path in m3u8 with filename
before patch:
localhost:osx liuqi$ tree 20160926/
20160926/
└── file-20160909
└── 26
└── 16
└── 15
├── 46
│ ├── 13.ts
│ ├── 25.ts
│ ├── 36.ts
│ ├── 45.ts
│ └── 54.ts
└── 47
├── 04.ts
├── 14.ts
├── 24.ts
└── 35.ts
6 directories, 9 files
localhost:osx liuqi$ cat out.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:12
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:11.360000,
13.ts
#EXTINF:10.800000,
25.ts
#EXTINF:9.120000,
36.ts
#EXTINF:8.760000,
45.ts
#EXTINF:10.200000,
54.ts
#EXTINF:10.720000,
04.ts
#EXTINF:9.600000,
14.ts
#EXTINF:10.600000,
24.ts
#EXTINF:8.760000,
35.ts
#EXT-X-ENDLIST
after patch:
localhost:osx liuqi$ tree 20160926/
20160926/
└── file-20160909
└── 26
└── 16
└── 15
├── 46
│ ├── 13.ts
│ ├── 25.ts
│ ├── 36.ts
│ ├── 45.ts
│ └── 54.ts
└── 47
├── 04.ts
├── 14.ts
├── 24.ts
└── 35.ts
6 directories, 9 files
localhost:osx liuqi$ cat out.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:12
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:11.360000,
20160926/file-20160909/26/16/15/46/13.ts
#EXTINF:10.800000,
20160926/file-20160909/26/16/15/46/25.ts
#EXTINF:9.120000,
20160926/file-20160909/26/16/15/46/36.ts
#EXTINF:8.760000,
20160926/file-20160909/26/16/15/46/45.ts
#EXTINF:10.200000,
20160926/file-20160909/26/16/15/46/54.ts
#EXTINF:10.720000,
20160926/file-20160909/26/16/15/47/04.ts
#EXTINF:9.600000,
20160926/file-20160909/26/16/15/47/14.ts
#EXTINF:10.600000,
20160926/file-20160909/26/16/15/47/24.ts
#EXTINF:8.760000,
20160926/file-20160909/26/16/15/47/35.ts
#EXT-X-ENDLIST
Signed-off-by: Steven Liu <lingjiujianke@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/hlsenc.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index c1619373bf..e0bb44b364 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -364,8 +364,7 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double int64_t pos, int64_t size) { HLSSegment *en = av_malloc(sizeof(*en)); - char *tmp, *p; - const char *pl_dir, *filename; + const char *filename; int ret; if (!en) @@ -374,19 +373,7 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double filename = av_basename(hls->avf->filename); if (hls->use_localtime_mkdir) { - /* Possibly prefix with mkdir'ed subdir, if playlist share same - * base path. */ - tmp = av_strdup(s->filename); - if (!tmp) { - av_free(en); - return AVERROR(ENOMEM); - } - - pl_dir = av_dirname(tmp); - p = hls->avf->filename; - if (strstr(p, pl_dir) == p) - filename = hls->avf->filename + strlen(pl_dir) + 1; - av_free(tmp); + filename = hls->avf->filename; } av_strlcpy(en->filename, filename, sizeof(en->filename)); |