ismindex.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012 Martin Storsjo
3  *
4  * This file is part of Libav.
5  *
6  * Libav is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * Libav 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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with Libav; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * To create a simple file for smooth streaming:
23  * avconv <normal input/transcoding options> -movflags frag_keyframe foo.ismv
24  * ismindex -n foo foo.ismv
25  * This step creates foo.ism and foo.ismc that is required by IIS for
26  * serving it.
27  *
28  * To pre-split files for serving as static files by a web server without
29  * any extra server support, create the ismv file as above, and split it:
30  * ismindex -split foo.ismv
31  * This step creates a file Manifest and directories QualityLevel(...),
32  * that can be read directly by a smooth streaming player.
33  */
34 
35 #include <stdio.h>
36 #include <string.h>
37 #include <sys/stat.h>
38 #ifdef _WIN32
39 #include <direct.h>
40 #define mkdir(a, b) _mkdir(a)
41 #endif
42 
43 #include "libavformat/avformat.h"
44 #include "libavutil/intreadwrite.h"
45 #include "libavutil/mathematics.h"
46 
47 static int usage(const char *argv0, int ret)
48 {
49  fprintf(stderr, "%s [-split] [-n basename] file1 [file2] ...\n", argv0);
50  return ret;
51 }
52 
53 struct MoofOffset {
54  int64_t time;
55  int64_t offset;
56  int duration;
57 };
58 
59 struct VideoFile {
60  const char *name;
61  int64_t duration;
62  int bitrate;
63  int track_id;
65  int width, height;
66  int chunks;
71  int timescale;
72  const char *fourcc;
73  int blocksize;
74  int tag;
75 };
76 
77 struct VideoFiles {
78  int nb_files;
79  int64_t duration;
80  struct VideoFile **files;
83 };
84 
85 static int copy_tag(AVIOContext *in, AVIOContext *out, int32_t tag_name)
86 {
87  int32_t size, tag;
88 
89  size = avio_rb32(in);
90  tag = avio_rb32(in);
91  avio_wb32(out, size);
92  avio_wb32(out, tag);
93  if (tag != tag_name)
94  return -1;
95  size -= 8;
96  while (size > 0) {
97  char buf[1024];
98  int len = FFMIN(sizeof(buf), size);
99  if (avio_read(in, buf, len) != len)
100  break;
101  avio_write(out, buf, len);
102  size -= len;
103  }
104  return 0;
105 }
106 
107 static int write_fragment(const char *filename, AVIOContext *in)
108 {
109  AVIOContext *out = NULL;
110  int ret;
111 
112  if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, NULL, NULL)) < 0)
113  return ret;
114  copy_tag(in, out, MKBETAG('m', 'o', 'o', 'f'));
115  copy_tag(in, out, MKBETAG('m', 'd', 'a', 't'));
116 
117  avio_flush(out);
118  avio_close(out);
119 
120  return ret;
121 }
122 
123 static int write_fragments(struct VideoFiles *files, int start_index,
124  AVIOContext *in)
125 {
126  char dirname[100], filename[500];
127  int i, j;
128 
129  for (i = start_index; i < files->nb_files; i++) {
130  struct VideoFile *vf = files->files[i];
131  const char *type = vf->is_video ? "video" : "audio";
132  snprintf(dirname, sizeof(dirname), "QualityLevels(%d)", vf->bitrate);
133  mkdir(dirname, 0777);
134  for (j = 0; j < vf->chunks; j++) {
135  snprintf(filename, sizeof(filename), "%s/Fragments(%s=%"PRId64")",
136  dirname, type, vf->offsets[j].time);
137  avio_seek(in, vf->offsets[j].offset, SEEK_SET);
138  write_fragment(filename, in);
139  }
140  }
141  return 0;
142 }
143 
144 static int read_tfra(struct VideoFiles *files, int start_index, AVIOContext *f)
145 {
146  int ret = AVERROR_EOF, track_id;
147  int version, fieldlength, i, j;
148  int64_t pos = avio_tell(f);
149  uint32_t size = avio_rb32(f);
150  struct VideoFile *vf = NULL;
151 
152  if (avio_rb32(f) != MKBETAG('t', 'f', 'r', 'a'))
153  goto fail;
154  version = avio_r8(f);
155  avio_rb24(f);
156  track_id = avio_rb32(f); /* track id */
157  for (i = start_index; i < files->nb_files && !vf; i++)
158  if (files->files[i]->track_id == track_id)
159  vf = files->files[i];
160  if (!vf) {
161  /* Ok, continue parsing the next atom */
162  ret = 0;
163  goto fail;
164  }
165  fieldlength = avio_rb32(f);
166  vf->chunks = avio_rb32(f);
167  vf->offsets = av_mallocz(sizeof(*vf->offsets) * vf->chunks);
168  if (!vf->offsets) {
169  ret = AVERROR(ENOMEM);
170  goto fail;
171  }
172  for (i = 0; i < vf->chunks; i++) {
173  if (version == 1) {
174  vf->offsets[i].time = avio_rb64(f);
175  vf->offsets[i].offset = avio_rb64(f);
176  } else {
177  vf->offsets[i].time = avio_rb32(f);
178  vf->offsets[i].offset = avio_rb32(f);
179  }
180  for (j = 0; j < ((fieldlength >> 4) & 3) + 1; j++)
181  avio_r8(f);
182  for (j = 0; j < ((fieldlength >> 2) & 3) + 1; j++)
183  avio_r8(f);
184  for (j = 0; j < ((fieldlength >> 0) & 3) + 1; j++)
185  avio_r8(f);
186  if (i > 0)
187  vf->offsets[i - 1].duration = vf->offsets[i].time -
188  vf->offsets[i - 1].time;
189  }
190  if (vf->chunks > 0)
191  vf->offsets[vf->chunks - 1].duration = vf->duration -
192  vf->offsets[vf->chunks - 1].time;
193  ret = 0;
194 
195 fail:
196  avio_seek(f, pos + size, SEEK_SET);
197  return ret;
198 }
199 
200 static int read_mfra(struct VideoFiles *files, int start_index,
201  const char *file, int split)
202 {
203  int err = 0;
204  AVIOContext *f = NULL;
205  int32_t mfra_size;
206 
207  if ((err = avio_open2(&f, file, AVIO_FLAG_READ, NULL, NULL)) < 0)
208  goto fail;
209  avio_seek(f, avio_size(f) - 4, SEEK_SET);
210  mfra_size = avio_rb32(f);
211  avio_seek(f, -mfra_size, SEEK_CUR);
212  if (avio_rb32(f) != mfra_size) {
213  err = AVERROR_INVALIDDATA;
214  goto fail;
215  }
216  if (avio_rb32(f) != MKBETAG('m', 'f', 'r', 'a')) {
217  err = AVERROR_INVALIDDATA;
218  goto fail;
219  }
220  while (!read_tfra(files, start_index, f)) {
221  /* Empty */
222  }
223 
224  if (split)
225  write_fragments(files, start_index, f);
226 
227 fail:
228  if (f)
229  avio_close(f);
230  if (err)
231  fprintf(stderr, "Unable to read the MFRA atom in %s\n", file);
232  return err;
233 }
234 
235 static int get_private_data(struct VideoFile *vf, AVCodecContext *codec)
236 {
237  vf->codec_private_size = codec->extradata_size;
239  if (!vf->codec_private)
240  return AVERROR(ENOMEM);
241  memcpy(vf->codec_private, codec->extradata, codec->extradata_size);
242  return 0;
243 }
244 
245 static int get_video_private_data(struct VideoFile *vf, AVCodecContext *codec)
246 {
247  AVIOContext *io = NULL;
248  uint16_t sps_size, pps_size;
249  int err = AVERROR(EINVAL);
250 
251  if (codec->codec_id == AV_CODEC_ID_VC1)
252  return get_private_data(vf, codec);
253 
254  avio_open_dyn_buf(&io);
255  if (codec->extradata_size < 11 || codec->extradata[0] != 1)
256  goto fail;
257  sps_size = AV_RB16(&codec->extradata[6]);
258  if (11 + sps_size > codec->extradata_size)
259  goto fail;
260  avio_wb32(io, 0x00000001);
261  avio_write(io, &codec->extradata[8], sps_size);
262  pps_size = AV_RB16(&codec->extradata[9 + sps_size]);
263  if (11 + sps_size + pps_size > codec->extradata_size)
264  goto fail;
265  avio_wb32(io, 0x00000001);
266  avio_write(io, &codec->extradata[11 + sps_size], pps_size);
267  err = 0;
268 
269 fail:
271  return err;
272 }
273 
274 static int handle_file(struct VideoFiles *files, const char *file, int split)
275 {
276  AVFormatContext *ctx = NULL;
277  int err = 0, i, orig_files = files->nb_files;
278  char errbuf[50], *ptr;
279  struct VideoFile *vf;
280 
281  err = avformat_open_input(&ctx, file, NULL, NULL);
282  if (err < 0) {
283  av_strerror(err, errbuf, sizeof(errbuf));
284  fprintf(stderr, "Unable to open %s: %s\n", file, errbuf);
285  return 1;
286  }
287 
288  err = avformat_find_stream_info(ctx, NULL);
289  if (err < 0) {
290  av_strerror(err, errbuf, sizeof(errbuf));
291  fprintf(stderr, "Unable to identify %s: %s\n", file, errbuf);
292  goto fail;
293  }
294 
295  if (ctx->nb_streams < 1) {
296  fprintf(stderr, "No streams found in %s\n", file);
297  goto fail;
298  }
299  if (!files->duration)
300  files->duration = ctx->duration;
301 
302  for (i = 0; i < ctx->nb_streams; i++) {
303  AVStream *st = ctx->streams[i];
304  vf = av_mallocz(sizeof(*vf));
305  files->files = av_realloc(files->files,
306  sizeof(*files->files) * (files->nb_files + 1));
307  files->files[files->nb_files] = vf;
308 
309  vf->name = file;
310  if ((ptr = strrchr(file, '/')) != NULL)
311  vf->name = ptr + 1;
312 
313  vf->bitrate = st->codec->bit_rate;
314  vf->track_id = st->id;
315  vf->timescale = st->time_base.den;
316  vf->duration = av_rescale_rnd(ctx->duration, vf->timescale,
320 
321  if (!vf->is_audio && !vf->is_video) {
322  fprintf(stderr,
323  "Track %d in %s is neither video nor audio, skipping\n",
324  vf->track_id, file);
325  av_freep(&files->files[files->nb_files]);
326  continue;
327  }
328 
329  if (vf->is_audio) {
330  if (files->audio_file < 0)
331  files->audio_file = files->nb_files;
332  files->nb_audio_files++;
333  vf->channels = st->codec->channels;
334  vf->sample_rate = st->codec->sample_rate;
335  if (st->codec->codec_id == AV_CODEC_ID_AAC) {
336  vf->fourcc = "AACL";
337  vf->tag = 255;
338  vf->blocksize = 4;
339  } else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
340  vf->fourcc = "WMAP";
341  vf->tag = st->codec->codec_tag;
342  vf->blocksize = st->codec->block_align;
343  }
344  get_private_data(vf, st->codec);
345  }
346  if (vf->is_video) {
347  if (files->video_file < 0)
348  files->video_file = files->nb_files;
349  files->nb_video_files++;
350  vf->width = st->codec->width;
351  vf->height = st->codec->height;
352  if (st->codec->codec_id == AV_CODEC_ID_H264)
353  vf->fourcc = "H264";
354  else if (st->codec->codec_id == AV_CODEC_ID_VC1)
355  vf->fourcc = "WVC1";
356  get_video_private_data(vf, st->codec);
357  }
358 
359  files->nb_files++;
360  }
361 
362  avformat_close_input(&ctx);
363 
364  err = read_mfra(files, orig_files, file, split);
365 
366 fail:
367  if (ctx)
368  avformat_close_input(&ctx);
369  return err;
370 }
371 
372 static void output_server_manifest(struct VideoFiles *files,
373  const char *basename)
374 {
375  char filename[1000];
376  FILE *out;
377  int i;
378 
379  snprintf(filename, sizeof(filename), "%s.ism", basename);
380  out = fopen(filename, "w");
381  if (!out) {
382  perror(filename);
383  return;
384  }
385  fprintf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
386  fprintf(out, "<smil xmlns=\"http://www.w3.org/2001/SMIL20/Language\">\n");
387  fprintf(out, "\t<head>\n");
388  fprintf(out, "\t\t<meta name=\"clientManifestRelativePath\" "
389  "content=\"%s.ismc\" />\n", basename);
390  fprintf(out, "\t</head>\n");
391  fprintf(out, "\t<body>\n");
392  fprintf(out, "\t\t<switch>\n");
393  for (i = 0; i < files->nb_files; i++) {
394  struct VideoFile *vf = files->files[i];
395  const char *type = vf->is_video ? "video" : "audio";
396  fprintf(out, "\t\t\t<%s src=\"%s\" systemBitrate=\"%d\">\n",
397  type, vf->name, vf->bitrate);
398  fprintf(out, "\t\t\t\t<param name=\"trackID\" value=\"%d\" "
399  "valueType=\"data\" />\n", vf->track_id);
400  fprintf(out, "\t\t\t</%s>\n", type);
401  }
402  fprintf(out, "\t\t</switch>\n");
403  fprintf(out, "\t</body>\n");
404  fprintf(out, "</smil>\n");
405  fclose(out);
406 }
407 
408 static void output_client_manifest(struct VideoFiles *files,
409  const char *basename, int split)
410 {
411  char filename[1000];
412  FILE *out;
413  int i, j;
414 
415  if (split)
416  snprintf(filename, sizeof(filename), "Manifest");
417  else
418  snprintf(filename, sizeof(filename), "%s.ismc", basename);
419  out = fopen(filename, "w");
420  if (!out) {
421  perror(filename);
422  return;
423  }
424  fprintf(out, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
425  fprintf(out, "<SmoothStreamingMedia MajorVersion=\"2\" MinorVersion=\"0\" "
426  "Duration=\"%"PRId64 "\">\n", files->duration * 10);
427  if (files->video_file >= 0) {
428  struct VideoFile *vf = files->files[files->video_file];
429  struct VideoFile *first_vf = vf;
430  int index = 0;
431  fprintf(out,
432  "\t<StreamIndex Type=\"video\" QualityLevels=\"%d\" "
433  "Chunks=\"%d\" "
434  "Url=\"QualityLevels({bitrate})/Fragments(video={start time})\">\n",
435  files->nb_video_files, vf->chunks);
436  for (i = 0; i < files->nb_files; i++) {
437  vf = files->files[i];
438  if (!vf->is_video)
439  continue;
440  fprintf(out,
441  "\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
442  "FourCC=\"%s\" MaxWidth=\"%d\" MaxHeight=\"%d\" "
443  "CodecPrivateData=\"",
444  index, vf->bitrate, vf->fourcc, vf->width, vf->height);
445  for (j = 0; j < vf->codec_private_size; j++)
446  fprintf(out, "%02X", vf->codec_private[j]);
447  fprintf(out, "\" />\n");
448  index++;
449  if (vf->chunks != first_vf->chunks)
450  fprintf(stderr, "Mismatched number of video chunks in %s and %s\n",
451  vf->name, first_vf->name);
452  }
453  vf = first_vf;
454  for (i = 0; i < vf->chunks; i++) {
455  for (j = files->video_file + 1; j < files->nb_files; j++) {
456  if (files->files[j]->is_video &&
457  vf->offsets[i].duration != files->files[j]->offsets[i].duration)
458  fprintf(stderr, "Mismatched duration of video chunk %d in %s and %s\n",
459  i, vf->name, files->files[j]->name);
460  }
461  fprintf(out, "\t\t<c n=\"%d\" d=\"%d\" />\n", i,
462  vf->offsets[i].duration);
463  }
464  fprintf(out, "\t</StreamIndex>\n");
465  }
466  if (files->audio_file >= 0) {
467  struct VideoFile *vf = files->files[files->audio_file];
468  struct VideoFile *first_vf = vf;
469  int index = 0;
470  fprintf(out,
471  "\t<StreamIndex Type=\"audio\" QualityLevels=\"%d\" "
472  "Chunks=\"%d\" "
473  "Url=\"QualityLevels({bitrate})/Fragments(audio={start time})\">\n",
474  files->nb_audio_files, vf->chunks);
475  for (i = 0; i < files->nb_files; i++) {
476  vf = files->files[i];
477  if (!vf->is_audio)
478  continue;
479  fprintf(out,
480  "\t\t<QualityLevel Index=\"%d\" Bitrate=\"%d\" "
481  "FourCC=\"%s\" SamplingRate=\"%d\" Channels=\"%d\" "
482  "BitsPerSample=\"16\" PacketSize=\"%d\" "
483  "AudioTag=\"%d\" CodecPrivateData=\"",
484  index, vf->bitrate, vf->fourcc, vf->sample_rate,
485  vf->channels, vf->blocksize, vf->tag);
486  for (j = 0; j < vf->codec_private_size; j++)
487  fprintf(out, "%02X", vf->codec_private[j]);
488  fprintf(out, "\" />\n");
489  index++;
490  if (vf->chunks != first_vf->chunks)
491  fprintf(stderr, "Mismatched number of audio chunks in %s and %s\n",
492  vf->name, first_vf->name);
493  }
494  vf = first_vf;
495  for (i = 0; i < vf->chunks; i++) {
496  for (j = files->audio_file + 1; j < files->nb_files; j++) {
497  if (files->files[j]->is_audio &&
498  vf->offsets[i].duration != files->files[j]->offsets[i].duration)
499  fprintf(stderr, "Mismatched duration of audio chunk %d in %s and %s\n",
500  i, vf->name, files->files[j]->name);
501  }
502  fprintf(out, "\t\t<c n=\"%d\" d=\"%d\" />\n",
503  i, vf->offsets[i].duration);
504  }
505  fprintf(out, "\t</StreamIndex>\n");
506  }
507  fprintf(out, "</SmoothStreamingMedia>\n");
508  fclose(out);
509 }
510 
511 static void clean_files(struct VideoFiles *files)
512 {
513  int i;
514  for (i = 0; i < files->nb_files; i++) {
515  av_freep(&files->files[i]->codec_private);
516  av_freep(&files->files[i]->offsets);
517  av_freep(&files->files[i]);
518  }
519  av_freep(&files->files);
520  files->nb_files = 0;
521 }
522 
523 int main(int argc, char **argv)
524 {
525  const char *basename = NULL;
526  int split = 0, i;
527  struct VideoFiles vf = { 0, .video_file = -1, .audio_file = -1 };
528 
529  av_register_all();
530 
531  for (i = 1; i < argc; i++) {
532  if (!strcmp(argv[i], "-n")) {
533  basename = argv[i + 1];
534  i++;
535  } else if (!strcmp(argv[i], "-split")) {
536  split = 1;
537  } else if (argv[i][0] == '-') {
538  return usage(argv[0], 1);
539  } else {
540  if (handle_file(&vf, argv[i], split))
541  return 1;
542  }
543  }
544  if (!vf.nb_files || (!basename && !split))
545  return usage(argv[0], 1);
546 
547  if (!split)
548  output_server_manifest(&vf, basename);
549  output_client_manifest(&vf, basename, split);
550 
551  clean_files(&vf);
552 
553  return 0;
554 }
static int copy_tag(AVIOContext *in, AVIOContext *out, int32_t tag_name)
Definition: ismindex.c:85
struct MoofOffset * offsets
Definition: ismindex.c:70
static int handle_file(struct VideoFiles *files, const char *file, int split)
Definition: ismindex.c:274
static void clean_files(struct VideoFiles *files)
Definition: ismindex.c:511
Bytestream IO Context.
Definition: avio.h:68
int64_t avio_size(AVIOContext *s)
Get the filesize.
Definition: aviobuf.c:241
int size
int chunks
Definition: ismindex.c:66
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
Definition: aviobuf.c:945
static int usage(const char *argv0, int ret)
Definition: ismindex.c:47
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.
Definition: mathematics.c:58
int height
Definition: ismindex.c:65
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
Definition: utils.c:476
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
Definition: aviobuf.c:186
const char * name
Definition: ismindex.c:60
static int read_tfra(struct VideoFiles *files, int start_index, AVIOContext *f)
Definition: ismindex.c:144
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Definition: aviobuf.c:933
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
Definition: avcodec.h:2141
int64_t duration
Definition: ismindex.c:79
int timescale
Definition: ismindex.c:71
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:151
Format I/O context.
Definition: avformat.h:828
int64_t duration
Definition: ismindex.c:61
uint8_t
Round toward +infinity.
Definition: mathematics.h:53
unsigned int avio_rb32(AVIOContext *s)
Definition: aviobuf.c:577
int id
Format-specific stream ID.
Definition: avformat.h:629
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1454
AVStream ** streams
Definition: avformat.h:876
int channels
Definition: ismindex.c:67
uint32_t tag
Definition: movenc.c:802
int width
Definition: ismindex.c:65
int64_t time
Definition: ismindex.c:54
uint64_t avio_rb64(AVIOContext *s)
Definition: aviobuf.c:642
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
Definition: avio.h:219
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
Definition: aviobuf.c:165
static int write_fragment(const char *filename, AVIOContext *in)
Definition: ismindex.c:107
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
Definition: aviobuf.c:446
uint8_t * codec_private
Definition: ismindex.c:68
int track_id
Definition: ismindex.c:63
int nb_video_files
Definition: ismindex.c:82
struct VideoFile ** files
Definition: ismindex.c:80
int is_video
Definition: ismindex.c:64
#define AV_RB16
Definition: intreadwrite.h:53
static void output_server_manifest(struct VideoFiles *files, const char *basename)
Definition: ismindex.c:372
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
Definition: aviobuf.c:782
int audio_file
Definition: ismindex.c:81
int nb_files
Definition: ismindex.c:78
static char * split(char *message, char delim)
Definition: af_channelmap.c:86
int avio_r8(AVIOContext *s)
Definition: aviobuf.c:437
AVCodecContext * codec
Codec context associated with this stream.
Definition: avformat.h:641
unsigned int nb_streams
A list of all streams in the file.
Definition: avformat.h:875
int bit_rate
the average bitrate
Definition: avcodec.h:1404
int void avio_flush(AVIOContext *s)
Definition: aviobuf.c:180
unsigned int avio_rb24(AVIOContext *s)
Definition: aviobuf.c:570
int sample_rate
Definition: ismindex.c:67
int width
picture width / height.
Definition: avcodec.h:1508
int blocksize
Definition: ismindex.c:73
static int get_video_private_data(struct VideoFile *vf, AVCodecContext *codec)
Definition: ismindex.c:245
int32_t
static void output_client_manifest(struct VideoFiles *files, const char *basename, int split)
Definition: ismindex.c:408
int bitrate
Definition: ismindex.c:62
int nb_audio_files
Definition: ismindex.c:82
Stream structure.
Definition: avformat.h:622
NULL
Definition: eval.c:52
enum AVMediaType codec_type
Definition: avcodec.h:1347
version
Definition: ffv1enc.c:1069
enum AVCodecID codec_id
Definition: avcodec.h:1350
int sample_rate
samples per second
Definition: avcodec.h:2104
main external API structure.
Definition: avcodec.h:1339
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
Definition: avcodec.h:1365
int extradata_size
Definition: avcodec.h:1455
int index
Definition: gxfenc.c:72
int video_file
Definition: ismindex.c:81
static int get_private_data(struct VideoFile *vf, AVCodecContext *codec)
Definition: ismindex.c:235
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
Definition: aviobuf.c:765
static int write_fragments(struct VideoFiles *files, int start_index, AVIOContext *in)
Definition: ismindex.c:123
int av_strerror(int errnum, char *errbuf, size_t errbuf_size)
Put a description of the AVERROR code errnum in errbuf.
Definition: error.c:23
static int read_mfra(struct VideoFiles *files, int start_index, const char *file, int split)
Definition: ismindex.c:200
const char * fourcc
Definition: ismindex.c:72
Main libavformat public API header.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
Definition: mem.c:116
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
Definition: utils.c:2236
int den
denominator
Definition: rational.h:45
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
Definition: utils.c:2713
int duration
Definition: ismindex.c:56
int len
int channels
number of audio channels
Definition: avcodec.h:2105
int tag
Definition: ismindex.c:74
void avio_wb32(AVIOContext *s, unsigned int val)
Definition: aviobuf.c:268
int64_t duration
Decoding: duration of the stream, in AV_TIME_BASE fractional seconds.
Definition: avformat.h:893
int main(int argc, char **argv)
Definition: ismindex.c:523
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avformat.h:669
void av_register_all(void)
Initialize libavformat and register all the muxers, demuxers and protocols.
Definition: allformats.c:52
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
Definition: mem.c:158
int is_audio
Definition: ismindex.c:64
int codec_private_size
Definition: ismindex.c:69
int64_t offset
Definition: ismindex.c:55