diff options
Diffstat (limited to 'tools/qt-faststart.c')
-rw-r--r-- | tools/qt-faststart.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c index 0db5ca2138..97be019c58 100644 --- a/tools/qt-faststart.c +++ b/tools/qt-faststart.c @@ -8,7 +8,7 @@ * is in front of the data, thus facilitating network streaming. * * To compile this program, start from the base directory from which you - * are building Libav and type: + * are building FFmpeg 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 @@ -83,7 +83,7 @@ #define CO64_ATOM QT_ATOM('c', 'o', '6', '4') #define ATOM_PREAMBLE_SIZE 8 -#define COPY_BUFFER_SIZE 65536 +#define COPY_BUFFER_SIZE 33554432 int main(int argc, char *argv[]) { @@ -102,12 +102,12 @@ int main(int argc, char *argv[]) uint32_t offset_count; uint64_t current_offset; int64_t start_offset = 0; - unsigned char copy_buffer[COPY_BUFFER_SIZE]; + unsigned char *copy_buffer = NULL; int bytes_to_copy; if (argc != 3) { printf("Usage: qt-faststart <infile.mov> <outfile.mov>\n" - "Note: alternatively you can use -movflags +faststart in avconv\n"); + "Note: alternatively you can use -movflags +faststart in ffmpeg\n"); return 0; } @@ -324,9 +324,15 @@ int main(int argc, char *argv[]) } /* copy the remainder of the infile, from offset 0 -> last_offset - 1 */ + bytes_to_copy = MIN(COPY_BUFFER_SIZE, last_offset); + copy_buffer = malloc(bytes_to_copy); + if (!copy_buffer) { + printf("could not allocate %d bytes for copy_buffer\n", bytes_to_copy); + goto error_out; + } printf(" copying rest of file...\n"); while (last_offset) { - bytes_to_copy = MIN(COPY_BUFFER_SIZE, last_offset); + bytes_to_copy = MIN(bytes_to_copy, last_offset); if (fread(copy_buffer, bytes_to_copy, 1, infile) != 1) { perror(argv[1]); @@ -343,6 +349,7 @@ int main(int argc, char *argv[]) fclose(outfile); free(moov_atom); free(ftyp_atom); + free(copy_buffer); return 0; @@ -353,5 +360,6 @@ error_out: fclose(outfile); free(moov_atom); free(ftyp_atom); + free(copy_buffer); return 1; } |