summaryrefslogtreecommitdiff
path: root/qt-faststart.c
diff options
context:
space:
mode:
authorBaptiste Coudurier <baptiste.coudurier@gmail.com>2006-03-16 16:37:05 +0000
committerBaptiste Coudurier <baptiste.coudurier@gmail.com>2006-03-16 16:37:05 +0000
commit60a9cc5879696adf46a267f4b5c1508f6d713b39 (patch)
treef7bbf4a4e848b5cc99c37e3911c0f314955a2121 /qt-faststart.c
parentc03395995ac9a9e407543bc05ba43c4c392338e5 (diff)
downloadffmpeg-60a9cc5879696adf46a267f4b5c1508f6d713b39.tar.gz
keep ftyp first
Originally committed as revision 5170 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'qt-faststart.c')
-rw-r--r--qt-faststart.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/qt-faststart.c b/qt-faststart.c
index 66043798b7..b4eba7bb56 100644
--- a/qt-faststart.c
+++ b/qt-faststart.c
@@ -72,10 +72,13 @@ int main(int argc, char *argv[])
uint64_t atom_size = 0;
uint64_t last_offset;
unsigned char *moov_atom;
+ unsigned char *ftyp_atom = 0;
uint64_t moov_atom_size;
+ uint64_t ftyp_atom_size = 0;
uint64_t i, j;
uint32_t offset_count;
uint64_t current_offset;
+ uint64_t start_offset = 0;
unsigned char copy_buffer[COPY_BUFFER_SIZE];
int bytes_to_copy;
@@ -112,6 +115,27 @@ int main(int argc, char *argv[])
break;
}
+ /* keep ftyp atom */
+ if (atom_type == FTYP_ATOM) {
+ ftyp_atom_size = atom_size;
+ ftyp_atom = malloc(ftyp_atom_size);
+ if (!ftyp_atom) {
+ printf ("could not allocate 0x%llX byte for ftyp atom\n",
+ atom_size);
+ fclose(infile);
+ return 1;
+ }
+ fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
+ if (fread(ftyp_atom, atom_size, 1, infile) != 1) {
+ perror(argv[1]);
+ free(ftyp_atom);
+ fclose(infile);
+ return 1;
+ }
+ start_offset = ftello(infile);
+ continue;
+ }
+
/* 64-bit special case */
if (atom_size == 1) {
if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
@@ -214,6 +238,9 @@ int main(int argc, char *argv[])
free(moov_atom);
return 1;
}
+ /* seek after ftyp atom if needed */
+ fseeko(infile, start_offset, SEEK_SET);
+
outfile = fopen(argv[2], "wb");
if (!outfile) {
perror(argv[2]);
@@ -222,6 +249,15 @@ int main(int argc, char *argv[])
return 1;
}
+ /* dump the same ftyp atom */
+ if (ftyp_atom_size > 0) {
+ printf (" writing ftyp atom...\n");
+ if (fwrite(ftyp_atom, ftyp_atom_size, 1, outfile) != 1) {
+ perror(argv[2]);
+ goto error_out;
+ }
+ }
+
/* dump the new moov atom */
printf (" writing moov atom...\n");
if (fwrite(moov_atom, moov_atom_size, 1, outfile) != 1) {