MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / write_fragments

Function write_fragments

tools/ismindex.c:174–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

172}
173
174static int write_fragments(struct Tracks *tracks, int start_index,
175 AVIOContext *in, const char *basename,
176 int split, int ismf, const char* output_prefix)
177{
178 char dirname[2048], filename[2048], idxname[2048];
179 int i, j, ret = 0, fragment_ret;
180 FILE* out = NULL;
181
182 if (ismf) {
183 snprintf(idxname, sizeof(idxname), "%s%s.ismf", output_prefix, basename);
184 out = fopen(idxname, "w");
185 if (!out) {
186 ret = AVERROR(errno);
187 perror(idxname);
188 goto fail;
189 }
190 }
191 for (i = start_index; i < tracks->nb_tracks; i++) {
192 struct Track *track = tracks->tracks[i];
193 const char *type = track->is_video ? "video" : "audio";
194 snprintf(dirname, sizeof(dirname), "%sQualityLevels(%d)", output_prefix, track->bitrate);
195 if (split) {
196 if (mkdir(dirname, 0777) == -1 && errno != EEXIST) {
197 ret = AVERROR(errno);
198 perror(dirname);
199 goto fail;
200 }
201 }
202 for (j = 0; j < track->chunks; j++) {
203 snprintf(filename, sizeof(filename), "%s/Fragments(%s=%"PRId64")",
204 dirname, type, track->offsets[j].time);
205 avio_seek(in, track->offsets[j].offset, SEEK_SET);
206 if (ismf)
207 fprintf(out, "%s %"PRId64, filename, avio_tell(in));
208 if (split)
209 fragment_ret = write_fragment(filename, in);
210 else
211 fragment_ret = skip_fragment(in);
212 if (ismf)
213 fprintf(out, " %"PRId64"\n", avio_tell(in));
214 if (fragment_ret != 0) {
215 fprintf(stderr, "failed fragment %d in track %d (%s)\n", j,
216 track->track_id, track->name);
217 ret = fragment_ret;
218 }
219 }
220 }
221fail:
222 if (out)
223 fclose(out);
224 return ret;
225}
226
227static int64_t read_trun_duration(AVIOContext *in, int default_duration,
228 int64_t end)

Callers 1

read_mfraFunction · 0.85

Calls 4

avio_seekFunction · 0.85
avio_tellFunction · 0.85
write_fragmentFunction · 0.85
skip_fragmentFunction · 0.85

Tested by

no test coverage detected