1 /*
2 * Copyright (c) 2012 Nicolas George
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
26
32
33 typedef struct {
41
43 {
44 return memcmp(probe->
buf,
"ffconcat version 1.0", 20) ?
46 }
47
49 {
50 char *ret = *cursor += strspn(*cursor,
SPACE_CHARS);
52 if (**cursor) {
53 *((*cursor)++) = 0;
55 }
56 return ret;
57 }
58
60 {
61 const char *start = f;
62
63 for (; *f; f++) {
64 /* A-Za-z0-9_- */
65 if (!((unsigned)((*f | 32) - 'a') < 26 ||
66 (unsigned)(*f - '0') < 10 || *f == '_' || *f == '-')) {
67 if (f == start)
68 return 0;
69 else if (*f == '/')
70 start = f + 1;
71 else if (*f != '.')
72 return 0;
73 }
74 }
75 return 1;
76 }
77
78 #define FAIL(retcode) do { ret = (retcode); goto fail; } while(0)
79
81 unsigned *nb_files_alloc)
82 {
85 char *url;
86 size_t url_len;
87
91 }
92 url_len = strlen(avf->
filename) + strlen(filename) + 16;
97
98 if (cat->
nb_files >= *nb_files_alloc) {
99 size_t n =
FFMAX(*nb_files_alloc * 2, 16);
101 if (n <= cat->nb_files || n > SIZE_MAX /
sizeof(*cat->
files) ||
104 cat->
files = new_files;
105 *nb_files_alloc = n;
106 }
107
109 memset(file, 0, sizeof(*file));
110 *rfile = file;
111
115
116 return 0;
117 }
118
120 {
123 int ret;
124
128 return ret;
129 }
135 return 0;
136 }
137
139 {
141 unsigned i;
142
148 return 0;
149 }
150
152 {
156 int ret,
line = 0, i;
157 unsigned nb_files_alloc = 0;
160 int64_t time = 0;
161
162 while (1) {
164 break;
165 line++;
166 cursor = buf;
168 if (!*keyword || *keyword == '#')
169 continue;
170
171 if (!strcmp(keyword, "file")) {
173 if (!filename) {
176 }
177 if ((ret =
add_file(avf, filename, &file, &nb_files_alloc)) < 0)
179 } else if (!strcmp(keyword, "duration")) {
181 int64_t dur;
182 if (!file) {
184 line);
186 }
189 line, dur_str);
191 }
193 } else if (!strcmp(keyword, "ffconcat")) {
196 if (strcmp(ver_kw, "version") || strcmp(ver_val, "1.0")) {
199 }
202 } else {
204 line, keyword);
206 }
207 }
208 if (ret < 0)
210
211 for (i = 0; i < cat->
nb_files; i++) {
214 else
217 break;
219 }
222
231 st->r_frame_rate = source_st->r_frame_rate;
235 }
236
237 return 0;
238
239 fail:
241 return ret;
242 }
243
245 {
248
251
256 }
257
259 {
261 int ret;
263
264 while (1) {
267 break;
268 }
276 return ret;
277 }
278
279 #define OFFSET(x) offsetof(ConcatContext, x)
280 #define DEC AV_OPT_FLAG_DECODING_PARAM
281
283 { "safe", "enable safe mode",
286 };
287
293 };
294
295
304 .priv_class = &concat_class,
305 };