* is in front of the data, thus facilitating network streaming.
*
* To compile this program, start from the base directory from which you
- * are building FFmpeg and type:
+ * are building Libav and type:
* make tools/qt-faststart
* The qt-faststart program will be built in the tools/ directory. If you
* do not build the program in this manner, correct results are not
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
+#include <string.h>
#ifdef __MINGW32__
#define fseeko(x,y,z) fseeko64(x,y,z)
uint64_t atom_offset = 0;
uint64_t last_offset;
unsigned char *moov_atom = NULL;
- unsigned char *ftyp_atom = 0;
+ unsigned char *ftyp_atom = NULL;
uint64_t moov_atom_size;
uint64_t ftyp_atom_size = 0;
uint64_t i, j;
return 0;
}
+ if (!strcmp(argv[1], argv[2])) {
+ fprintf(stderr, "input and output files need to be different\n");
+ return 1;
+ }
+
infile = fopen(argv[1], "rb");
if (!infile) {
perror(argv[1]);
break;
}
atom_offset += atom_size;
+
+ /* The atom header is 8 (or 16 bytes), if the atom size (which
+ * includes these 8 or 16 bytes) is less than that, we won't be
+ * able to continue scanning sensibly after this atom, so break. */
+ if (atom_size < 8)
+ break;
}
if (atom_type != MOOV_ATOM) {
error_out:
if (infile)
- fclose(infile);
+ fclose(infile);
if (outfile)
- fclose(outfile);
+ fclose(outfile);
free(moov_atom);
free(ftyp_atom);
return 1;