Go to the documentation of this file.
32 fprintf(stderr,
"%s -out foo.mpd file1\n", argv0);
89 while (!
f->eof_reached) {
121 int err = 0,
i, orig_tracks = tracks->
nb_tracks;
122 char errbuf[50], *ptr;
128 fprintf(stderr,
"Unable to open %s: %s\n", file, errbuf);
135 fprintf(stderr,
"Unable to identify %s: %s\n", file, errbuf);
140 fprintf(stderr,
"No streams found in %s\n", file);
151 fprintf(stderr,
"Skipping track %d in %s as it has zero bitrate\n",
172 if ((ptr = strrchr(file,
'/')))
173 track->
name = ptr + 1;
184 "Track %d in %s is neither video nor audio, skipping\n",
209 err =
find_sidx(tracks, orig_tracks, file);
221 int minutes = seconds / 60;
222 int hours = minutes / 60;
228 fprintf(
out,
"%dH", hours);
229 if (hours || minutes)
230 fprintf(
out,
"%dM", minutes);
231 fprintf(
out,
"%d.%0*dS", seconds, decimals, fractions);
238 struct Track **adaptation_sets_buf[2] = {
NULL };
239 struct Track ***adaptation_sets;
240 int nb_tracks_buf[2] = { 0 };
245 adaptation_sets = adaptation_sets_buf;
246 nb_tracks = nb_tracks_buf;
248 for (
i = 0;
i < 2;
i++) {
250 if (!adaptation_sets[
i]) {
263 adaptation_sets[set_index][nb_tracks[set_index]++] = tracks->
tracks[
i];
266 adaptation_sets = &tracks->
tracks;
271 out = fopen(filename,
"w");
277 fprintf(
out,
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
278 fprintf(
out,
"<MPD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
279 "\txmlns=\"urn:mpeg:dash:schema:mpd:2011\"\n"
280 "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n"
281 "\txsi:schemaLocation=\"urn:mpeg:DASH:schema:MPD:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd\"\n"
282 "\tprofiles=\"urn:mpeg:dash:profile:isoff-on-demand:2011\"\n"
283 "\ttype=\"static\"\n");
284 fprintf(
out,
"\tmediaPresentationDuration=\"");
286 fprintf(
out,
"\"\n");
287 fprintf(
out,
"\tminBufferTime=\"PT5S\">\n");
289 fprintf(
out,
"\t<Period start=\"PT0.0S\">\n");
292 if (nb_tracks[
set] == 0)
294 fprintf(
out,
"\t\t<AdaptationSet segmentAlignment=\"true\">\n");
296 for (
i = 0;
i < nb_tracks[
set];
i++) {
297 struct Track *track = adaptation_sets[
set][
i];
298 if (strcmp(track->
name, adaptation_sets[
set][0]->
name))
300 fprintf(
out,
"\t\t\t<ContentComponent id=\"%d\" contentType=\"%s\" />\n", track->
track_id, track->
is_audio ?
"audio" :
"video");
304 for (
i = 0;
i < nb_tracks[
set]; ) {
305 struct Track *first_track = adaptation_sets[
set][
i];
307 fprintf(
out,
"\t\t\t<Representation id=\"%d\" codecs=\"",
i);
308 for (j =
i; j < nb_tracks[
set]; j++) {
309 struct Track *track = adaptation_sets[
set][j];
310 if (strcmp(track->
name, first_track->
name))
325 fprintf(
out,
"\" mimeType=\"%s/mp4\" bandwidth=\"%d\"",
333 fprintf(
out,
"\t\t\t\t<AudioChannelConfiguration schemeIdUri=\"urn:mpeg:dash:23003:3:audio_channel_configuration:2011\" value=\"%d\" />\n",
channels);
334 fprintf(
out,
"\t\t\t\t<BaseURL>%s</BaseURL>\n", first_track->
name);
336 fprintf(
out,
"\t\t\t</Representation>\n");
339 fprintf(
out,
"\t\t</AdaptationSet>\n");
341 fprintf(
out,
"\t</Period>\n");
342 fprintf(
out,
"</MPD>\n");
346 for (
i = 0;
i < 2;
i++)
361 int main(
int argc,
char **argv)
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);
static void set_codec_str(AVCodecParameters *codecpar, char *str, int size)
@ AV_ROUND_UP
Round toward +infinity.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
enum AVMediaType codec_type
General type of the encoded data.
This struct describes the properties of an encoded stream.
static int handle_file(struct Tracks *tracks, const char *file)
AVStream ** streams
A list of all streams in the file.
AVRounding
Rounding methods.
int nb_channels
Number of channels in this layout.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
static int usage(const char *argv0, int ret)
static void clean_tracks(struct Tracks *tracks)
static int find_sidx(struct Tracks *tracks, int start_index, const char *file)
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rb32(AVIOContext *s)
static void set(uint8_t *a[], int ch, int index, int ch_count, enum AVSampleFormat f, double v)
int avformat_open_input(AVFormatContext **ps, const char *url, const AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
static void write_time(FILE *out, int64_t time, int decimals, enum AVRounding round)
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
AVChannelLayout ch_layout
Audio only.
int sample_rate
Audio only.
int extradata_size
Size of the extradata content in bytes.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
@ AV_ROUND_DOWN
Round toward -infinity.
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
int multiple_tracks_per_file
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
#define MKBETAG(a, b, c, d)
#define i(width, name, range_min, range_max)
static av_always_inline av_const double round(double x)
#define AV_TIME_BASE
Internal time base represented as integer.
#define av_malloc_array(a, b)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int id
Format-specific stream ID.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
static int output_mpd(struct Tracks *tracks, const char *filename)
int main(int argc, char **argv)
#define AVIO_FLAG_READ
read-only
int avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16