31 fprintf(stderr,
"%s -out foo.mpd file1\n", argv0);
95 if (tag ==
MKBETAG(
's',
'i',
'd',
'x')) {
96 for (i = start_index; i < tracks->
nb_tracks; i++) {
106 if (
avio_seek(f, pos + size, SEEK_SET) != pos + size)
119 int err = 0, i, orig_tracks = tracks->
nb_tracks;
120 char errbuf[50], *ptr;
126 fprintf(stderr,
"Unable to open %s: %s\n", file, errbuf);
133 fprintf(stderr,
"Unable to identify %s: %s\n", file, errbuf);
138 fprintf(stderr,
"No streams found in %s\n", file);
149 fprintf(stderr,
"Skipping track %d in %s as it has zero bitrate\n",
170 if ((ptr = strrchr(file,
'/')))
171 track->
name = ptr + 1;
182 "Track %d in %s is neither video nor audio, skipping\n",
207 err =
find_sidx(tracks, orig_tracks, file);
219 int minutes = seconds / 60;
220 int hours = minutes / 60;
226 fprintf(out,
"%dH", hours);
227 if (hours || minutes)
228 fprintf(out,
"%dM", minutes);
229 fprintf(out,
"%d.%0*dS", seconds, decimals, fractions);
236 struct Track **adaptation_sets_buf[2] = {
NULL };
237 struct Track ***adaptation_sets;
238 int nb_tracks_buf[2] = { 0 };
243 adaptation_sets = adaptation_sets_buf;
244 nb_tracks = nb_tracks_buf;
246 for (i = 0; i < 2; i++) {
248 if (!adaptation_sets[i]) {
253 for (i = 0; i < tracks->
nb_tracks; i++) {
261 adaptation_sets[set_index][nb_tracks[set_index]++] = tracks->
tracks[i];
264 adaptation_sets = &tracks->
tracks;
269 out = fopen(filename,
"w");
275 fprintf(out,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
276 fprintf(out,
"<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
277 "\txmlns=\"urn:mpeg:dash:schema:mpd:2011\"\n"
278 "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
279 "\txsi:schemaLocation=\"urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd\"\n"
280 "\tprofiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"\n"
281 "\ttype=\"static\"\n");
282 fprintf(out,
"\tmediaPresentationDuration=\"");
284 fprintf(out,
"\"\n");
285 fprintf(out,
"\tminBufferTime=\"PT5S\">\n");
287 fprintf(out,
"\t<Period start=\"PT0.0S\">\n");
289 for (
set = 0;
set < nb_sets;
set++) {
290 if (nb_tracks[
set] == 0)
292 fprintf(out,
"\t\t<AdaptationSet segmentAlignment=\"true\">\n");
294 for (i = 0; i < nb_tracks[
set]; i++) {
295 struct Track *track = adaptation_sets[
set][i];
296 if (strcmp(track->
name, adaptation_sets[
set][0]->
name))
298 fprintf(out,
"\t\t\t<ContentComponent id=\"%d\" contentType=\"%s\" />\n", track->
track_id, track->
is_audio ?
"audio" :
"video");
302 for (i = 0; i < nb_tracks[
set]; ) {
303 struct Track *first_track = adaptation_sets[
set][i];
305 fprintf(out,
"\t\t\t<Representation id=\"%d\" codecs=\"", i);
306 for (j = i; j < nb_tracks[
set]; j++) {
307 struct Track *track = adaptation_sets[
set][j];
308 if (strcmp(track->
name, first_track->
name))
315 width = track->
width;
323 fprintf(out,
"\" mimeType=\"%s/mp4\" bandwidth=\"%d\"",
324 width ?
"video" :
"audio",
bitrate);
325 if (width > 0 &&
height > 0)
326 fprintf(out,
" width=\"%d\" height=\"%d\"", width,
height);
328 fprintf(out,
" audioSamplingRate=\"%d\"",
sample_rate);
331 fprintf(out,
"\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n",
channels);
332 fprintf(out,
"\t\t\t\t<BaseURL>%s</BaseURL>\n", first_track->
name);
333 fprintf(out,
"\t\t\t\t<SegmentBase indexRange=\"%"PRId64
"-%"PRId64
"\" />\n", first_track->
sidx_start, first_track->
sidx_start + first_track->
sidx_length - 1);
334 fprintf(out,
"\t\t\t</Representation>\n");
337 fprintf(out,
"\t\t</AdaptationSet>\n");
339 fprintf(out,
"\t</Period>\n");
340 fprintf(out,
"</MPD>\n");
344 for (i = 0; i < 2; i++)
345 av_free(adaptation_sets_buf[i]);
352 for (i = 0; i < tracks->
nb_tracks; i++) {
359 int main(
int argc,
char **argv)
362 struct Tracks tracks = { 0 };
367 for (i = 1; i < argc; i++) {
368 if (!strcmp(argv[i],
"-out")) {
371 }
else if (argv[i][0] ==
'-') {
372 return usage(argv[0], 1);
379 return usage(argv[0], 1);