Discussion:
ffmpeg -qt -faststart - how to make it working?
(too old to reply)
Netman
2011-01-25 09:54:58 UTC
Permalink
Hello!

How to install -qt faststart parameter on ffmpeg for Windows XP system?
I use Winff application:

http://winff.org/html_new/downloads.html

and when I change the template by adding
-qt -faststart it generates the error:

ffmpeg.exe unrecognized option `-qt`

Can you tell me how to modify ffmpeg in winff file to make it possible?

Thank you in advance for help
Netm.
Gene E. Bloch
2011-01-25 18:33:19 UTC
Permalink
Post by Netman
Hello!
How to install -qt faststart parameter on ffmpeg for Windows XP system?
http://winff.org/html_new/downloads.html
and when I change the template by adding
ffmpeg.exe unrecognized option `-qt`
Can you tell me how to modify ffmpeg in winff file to make it possible?
Thank you in advance for help
Netm.
I just looked at the ffmpeg documentation page.

There's no option "qt" listed there, AFAICT.
--
Gene E. Bloch (Stumbling Bloch)
Frank
2011-01-26 01:29:04 UTC
Permalink
On Tue, 25 Jan 2011 10:33:19 -0800, in 'rec.video',
in article <Re: ffmpeg -qt -faststart - how to make it working?>,
Post by Gene E. Bloch
Post by Netman
Hello!
How to install -qt faststart parameter on ffmpeg for Windows XP system?
http://winff.org/html_new/downloads.html
and when I change the template by adding
ffmpeg.exe unrecognized option `-qt`
Can you tell me how to modify ffmpeg in winff file to make it possible?
Thank you in advance for help
Netm.
I just looked at the ffmpeg documentation page.
There's no option "qt" listed there, AFAICT.
Whether using WinFF or any other application, and whether it's one
that invokes ffmpeg or not, I usually create the file and then run it
through a program called qt-faststart.exe to relocate the moov atom.

Below are my notes on the qt-faststart.exe program. Note that no harm
is done to the file even if the moov atom is already up at the front
of the file. Also, in any case, the program usually only takes seconds
to run although since it copies over all of the data, a larger file
will take longer than a smaller file.

* * *

qt-faststart.exe

Downloaded from http://notboring.org/downloads/video/qt-faststart.zip

via a link found on the Web page at
http://notboring.org/devblog/2009/07/qt-faststartexe-binary-for-windows/

* * *

Program moves the moov Atom from the end of the file to the beginning
of the file.

The moov atom needs to be at the beginning of the file in order to
successfully pseudo-stream the file via HTTP.

The program works even on MPEG-4 AAC-LC audio files with an .mp4 file
extension!!!

* * *

Author's Web site:

http://multimedia.cx/eggs/autostreamable-ffmpeg/

and

http://multimedia.cx/eggs/improving-qt-faststart/

Source code: http://multimedia.cx/qt-faststart.c

* * *

Usage: qt-faststart <infile.mov> <outfile.mov>

Note: Filetype NEED NOT be .mov!

* * *

Good luck and hope this helps.
--
Frank, Independent Consultant, New York, NY
[Please remove 'nojunkmail.' from address to reply via e-mail.]
Read Frank's thoughts on HDV at http://www.humanvalues.net/hdv/
[also covers AVCHD (including AVCCAM & NXCAM) and XDCAM EX].
Gene E. Bloch
2011-01-27 00:45:12 UTC
Permalink
Post by Frank
On Tue, 25 Jan 2011 10:33:19 -0800, in 'rec.video',
in article <Re: ffmpeg -qt -faststart - how to make it working?>,
Post by Gene E. Bloch
Post by Netman
Hello!
How to install -qt faststart parameter on ffmpeg for Windows XP system?
http://winff.org/html_new/downloads.html
and when I change the template by adding
ffmpeg.exe unrecognized option `-qt`
Can you tell me how to modify ffmpeg in winff file to make it possible?
Thank you in advance for help
Netm.
I just looked at the ffmpeg documentation page.
There's no option "qt" listed there, AFAICT.
Whether using WinFF or any other application, and whether it's one
that invokes ffmpeg or not, I usually create the file and then run it
through a program called qt-faststart.exe to relocate the moov atom.
Below are my notes on the qt-faststart.exe program. Note that no harm
is done to the file even if the moov atom is already up at the front
of the file. Also, in any case, the program usually only takes seconds
to run although since it copies over all of the data, a larger file
will take longer than a smaller file.
* * *
qt-faststart.exe
Downloaded from http://notboring.org/downloads/video/qt-faststart.zip
via a link found on the Web page at
http://notboring.org/devblog/2009/07/qt-faststartexe-binary-for-windows/
* * *
Program moves the moov Atom from the end of the file to the beginning
of the file.
The moov atom needs to be at the beginning of the file in order to
successfully pseudo-stream the file via HTTP.
The program works even on MPEG-4 AAC-LC audio files with an .mp4 file
extension!!!
* * *
http://multimedia.cx/eggs/autostreamable-ffmpeg/
and
http://multimedia.cx/eggs/improving-qt-faststart/
Source code: http://multimedia.cx/qt-faststart.c
* * *
Usage: qt-faststart <infile.mov> <outfile.mov>
Note: Filetype NEED NOT be .mov!
* * *
Good luck and hope this helps.
Yes - let's hope this helps the OP...
--
Gene E. Bloch (Stumbling Bloch)
Frank
2011-01-27 02:39:29 UTC
Permalink
On Wed, 26 Jan 2011 16:45:12 -0800, in 'rec.video',
in article <Re: ffmpeg -qt -faststart - how to make it working?>,
Post by Gene E. Bloch
Post by Frank
On Tue, 25 Jan 2011 10:33:19 -0800, in 'rec.video',
in article <Re: ffmpeg -qt -faststart - how to make it working?>,
Post by Gene E. Bloch
Post by Netman
Hello!
How to install -qt faststart parameter on ffmpeg for Windows XP system?
http://winff.org/html_new/downloads.html
and when I change the template by adding
ffmpeg.exe unrecognized option `-qt`
Can you tell me how to modify ffmpeg in winff file to make it possible?
Thank you in advance for help
Netm.
I just looked at the ffmpeg documentation page.
There's no option "qt" listed there, AFAICT.
Whether using WinFF or any other application, and whether it's one
that invokes ffmpeg or not, I usually create the file and then run it
through a program called qt-faststart.exe to relocate the moov atom.
Below are my notes on the qt-faststart.exe program. Note that no harm
is done to the file even if the moov atom is already up at the front
of the file. Also, in any case, the program usually only takes seconds
to run although since it copies over all of the data, a larger file
will take longer than a smaller file.
* * *
qt-faststart.exe
Downloaded from http://notboring.org/downloads/video/qt-faststart.zip
via a link found on the Web page at
http://notboring.org/devblog/2009/07/qt-faststartexe-binary-for-windows/
* * *
Program moves the moov Atom from the end of the file to the beginning
of the file.
The moov atom needs to be at the beginning of the file in order to
successfully pseudo-stream the file via HTTP.
The program works even on MPEG-4 AAC-LC audio files with an .mp4 file
extension!!!
* * *
http://multimedia.cx/eggs/autostreamable-ffmpeg/
and
http://multimedia.cx/eggs/improving-qt-faststart/
Source code: http://multimedia.cx/qt-faststart.c
* * *
Usage: qt-faststart <infile.mov> <outfile.mov>
Note: Filetype NEED NOT be .mov!
* * *
Good luck and hope this helps.
Yes - let's hope this helps the OP...
It should (the program does work), although I failed to mention that I
don't go around creating .mov and .mp4 files and then blindly running
them through the qt-faststart.exe program, although no harm would be
done by doing so; it would merely be a waste of time when not
necessary.

Instead, what I actually do is to create the file and then take a
quick look at it in a hex editor program to see just where the moov
atom is located.

If I find that it's already positioned up at the beginning of the
file, then that's it, my job is done and there's no need to process
the file through a program such as qt-faststart.exe.

OTOH, if I find the moov atom down toward the end of the file, then I
run the file through qt-faststart.exe to relocate it.

BTW, for those who don't possess a hex editor program, you'll find
that Windows WordPad works just fine in this application. Just look
for the characters "moov" (without the quotes, of course) somewhere
within the first 50 to 100 bytes of the file. You can also do a Find
operation for the characters "moov". It will either be up toward the
start of the file (in which case you don't need to run the file
through the qt-faststart.exe program) or it will be down toward the
end of the file (in which case you probably will want to run the file
through the qt-faststart.exe program).

Note that I do this for virtually all .mov and .mp4 files that I
create, even if I have no immediate intent of placing it on a Web
server for pseudo-streaming purposes. This way, even if at some future
point in time I do decide to pseudo-stream it, I know that the file is
properly prepared and ready to go.

And again, I should mention that the qt-faststart.exe program works
for both audio-only as well as audio+video files, whether .mov or
.mp4, although 99 percent of the work that I do lately is .mp4
(MPEG-4): MPEG-4 AAC-LC audio and ISO/IEC 14496-10 MPEG-4 Part 10 AVC
/ ITU-T Rec. H.264 video.

Regards,
--
Frank, Independent Consultant, New York, NY
[Please remove 'nojunkmail.' from address to reply via e-mail.]
Read Frank's thoughts on HDV at http://www.humanvalues.net/hdv/
[also covers AVCHD (including AVCCAM & NXCAM) and XDCAM EX].
j***@gmail.com
2014-02-18 19:26:07 UTC
Permalink
I looked up the original source for qt-faststart -- an early version distinct from ffmpeg -- and made some simple changes to get it to compile under Win32. It's an early version; apparently there are better versions out there, but I couldn't find anything other than one that requires Python. This is a standalone program, taking input file and output file names.
Note: I am not the author. I just fixed the Win32 errors. This compiles w/VS 2010:
/*
* qt-faststart.c, v0.1
* by Mike Melanson (mike at multimedia.cx)
* This file is placed in the public domain. Use the program however you
* see fit.
*
* This utility rearranges a Quicktime file such that the moov atom
* is in front of the data, thus facilitating network streaming.
*
* Compile this program using:
* cc qt-faststart.c -o qt-faststart
* Invoke the program with:
* qt-faststart <infile.mov> <outfile.mov>
*
* Notes: Quicktime files can come in many configurations of top-level
* atoms. This utility stipulates that the very last atom in the file needs
* to be a moov atom. When given such a file, this utility will rearrange
* the top-level atoms by shifting the moov atom from the back of the file
* to the front, and patch the chunk offsets along the way. This utility
* presently only operates on uncompressed moov atoms.
*/

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>

#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
(((uint8_t*)(x))[1] << 16) | \
(((uint8_t*)(x))[2] << 8) | \
((uint8_t*)(x))[3])
#define BE_64(x) (((uint64_t)(((uint8_t*)(x))[0]) << 56) | \
((uint64_t)(((uint8_t*)(x))[1]) << 48) | \
((uint64_t)(((uint8_t*)(x))[2]) << 40) | \
((uint64_t)(((uint8_t*)(x))[3]) << 32) | \
((uint64_t)(((uint8_t*)(x))[4]) << 24) | \
((uint64_t)(((uint8_t*)(x))[5]) << 16) | \
((uint64_t)(((uint8_t*)(x))[6]) << 8) | \
((uint64_t)((uint8_t*)(x))[7]))

#define BE_FOURCC( ch0, ch1, ch2, ch3 ) \
( (uint32_t)(unsigned char)(ch3) | \
( (uint32_t)(unsigned char)(ch2) << 8 ) | \
( (uint32_t)(unsigned char)(ch1) << 16 ) | \
( (uint32_t)(unsigned char)(ch0) << 24 ) )

#define QT_ATOM BE_FOURCC
/* top level atoms */
#define FREE_ATOM QT_ATOM('f', 'r', 'e', 'e')
#define JUNK_ATOM QT_ATOM('j', 'u', 'n', 'k')
#define MDAT_ATOM QT_ATOM('m', 'd', 'a', 't')
#define MOOV_ATOM QT_ATOM('m', 'o', 'o', 'v')
#define PNOT_ATOM QT_ATOM('p', 'n', 'o', 't')
#define SKIP_ATOM QT_ATOM('s', 'k', 'i', 'p')
#define WIDE_ATOM QT_ATOM('w', 'i', 'd', 'e')
#define PICT_ATOM QT_ATOM('P', 'I', 'C', 'T')
#define FTYP_ATOM QT_ATOM('f', 't', 'y', 'p')

#define CMOV_ATOM QT_ATOM('c', 'm', 'o', 'v')
#define STCO_ATOM QT_ATOM('s', 't', 'c', 'o')
#define CO64_ATOM QT_ATOM('c', 'o', '6', '4')

#define ATOM_PREAMBLE_SIZE 8
#define COPY_BUFFER_SIZE 1024

int main(int argc, char *argv[])
{
FILE *infile;
FILE *outfile;
unsigned char atom_bytes[ATOM_PREAMBLE_SIZE];
uint32_t atom_type = 0;
uint64_t atom_size;
uint64_t last_offset;
unsigned char *moov_atom;
uint64_t moov_atom_size;
uint64_t i, j;
uint32_t offset_count;
uint64_t current_offset;
unsigned char copy_buffer[COPY_BUFFER_SIZE];
int bytes_to_copy;

if (argc != 3) {
printf ("Usage: qt-faststart <infile.mov> <outfile.mov>\n");
return 0;
}

infile = fopen(argv[1], "rb");
if (!infile) {
perror(argv[1]);
return 1;
}

/* traverse through the atoms in the file to make sure that 'moov' is
* at the end */
while (!feof(infile)) {
if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
break;
}
atom_size = BE_32(&atom_bytes[0]);
atom_type = BE_32(&atom_bytes[4]);

if ((atom_type != FREE_ATOM) &&
(atom_type != JUNK_ATOM) &&
(atom_type != MDAT_ATOM) &&
(atom_type != MOOV_ATOM) &&
(atom_type != PNOT_ATOM) &&
(atom_type != SKIP_ATOM) &&
(atom_type != WIDE_ATOM) &&
(atom_type != PICT_ATOM) &&
(atom_type != FTYP_ATOM)) {
printf ("encountered non-QT top-level atom (is this a Quicktime file?)\n");
break;
}

/* 64-bit special case */
if (atom_size == 1) {
if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
break;
}
atom_size = BE_64(&atom_bytes[0]);
fseek(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
} else {
fseek(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
}
}

if (atom_type != MOOV_ATOM) {
printf ("last atom in file was not a moov atom\n");
fclose(infile);
return 0;
}

/* moov atom was, in fact, the last atom in the chunk; load the whole
* moov atom */
fseek(infile, -atom_size, SEEK_END);
last_offset = (uint64_t)ftell(infile);
moov_atom_size = atom_size;
moov_atom = (unsigned char *) malloc(moov_atom_size);
if (!moov_atom) {
printf ("could not allocate 0x%llX byte for moov atom\n",
atom_size);
fclose(infile);
return 1;
}
if (fread(moov_atom, atom_size, 1, infile) != 1) {
perror(argv[1]);
free(moov_atom);
fclose(infile);
return 1;
}

/* this utility does not support compressed atoms yet, so disqualify
* files with compressed QT atoms */
if (BE_32(&moov_atom[12]) == CMOV_ATOM) {
printf ("this utility does not support compressed moov atoms yet\n");
free(moov_atom);
fclose(infile);
return 1;
}

/* close; will be re-opened later */
fclose(infile);

/* crawl through the moov chunk in search of stco or co64 atoms */
for (i = 4; i < moov_atom_size - 4; i++) {
atom_type = BE_32(&moov_atom[i]);
if (atom_type == STCO_ATOM) {
printf (" patching stco atom...\n");
atom_size = BE_32(&moov_atom[i - 4]);
if (i + atom_size - 4 > moov_atom_size) {
printf (" bad atom size\n");
free(moov_atom);
return 1;
}
offset_count = BE_32(&moov_atom[i + 8]);
for (j = 0; j < offset_count; j++) {
current_offset = BE_32(&moov_atom[i + 12 + j * 4]);
current_offset += moov_atom_size;
moov_atom[i + 12 + j * 4 + 0] = (current_offset >> 24) & 0xFF;
moov_atom[i + 12 + j * 4 + 1] = (current_offset >> 16) & 0xFF;
moov_atom[i + 12 + j * 4 + 2] = (current_offset >> 8) & 0xFF;
moov_atom[i + 12 + j * 4 + 3] = (current_offset >> 0) & 0xFF;
}
i += atom_size - 4;
} else if (atom_type == CO64_ATOM) {
printf (" patching co64 atom...\n");
atom_size = BE_32(&moov_atom[i - 4]);
if (i + atom_size - 4 > moov_atom_size) {
printf (" bad atom size\n");
free(moov_atom);
return 1;
}
offset_count = BE_32(&moov_atom[i + 8]);
for (j = 0; j < offset_count; j++) {
current_offset = BE_64(&moov_atom[i + 12 + j * 8]);
current_offset += moov_atom_size;
moov_atom[i + 12 + j * 8 + 0] = (current_offset >> 56) & 0xFF;
moov_atom[i + 12 + j * 8 + 1] = (current_offset >> 48) & 0xFF;
moov_atom[i + 12 + j * 8 + 2] = (current_offset >> 40) & 0xFF;
moov_atom[i + 12 + j * 8 + 3] = (current_offset >> 32) & 0xFF;
moov_atom[i + 12 + j * 8 + 4] = (current_offset >> 24) & 0xFF;
moov_atom[i + 12 + j * 8 + 5] = (current_offset >> 16) & 0xFF;
moov_atom[i + 12 + j * 8 + 6] = (current_offset >> 8) & 0xFF;
moov_atom[i + 12 + j * 8 + 7] = (current_offset >> 0) & 0xFF;
}
i += atom_size - 4;
}
}

/* re-open the input file and open the output file */
infile = fopen(argv[1], "rb");
if (!infile) {
perror(argv[1]);
free(moov_atom);
return 1;
}
outfile = fopen(argv[2], "wb");
if (!outfile) {
perror(argv[2]);
fclose(outfile);
free(moov_atom);
return 1;
}

/* dump the new moov atom */
printf (" writing moov atom...\n");
if (fwrite(moov_atom, moov_atom_size, 1, outfile) != 1) {
perror(argv[2]);
goto error_out;
}

/* copy the remainder of the infile, from offset 0 -> last_offset - 1 */
printf (" copying rest of file...\n");
while (last_offset) {
if (last_offset > COPY_BUFFER_SIZE)
bytes_to_copy = COPY_BUFFER_SIZE;
else
bytes_to_copy = last_offset;

if (fread(copy_buffer, bytes_to_copy, 1, infile) != 1) {
perror(argv[1]);
goto error_out;
}
if (fwrite(copy_buffer, bytes_to_copy, 1, outfile) != 1) {
perror(argv[2]);
goto error_out;
}

last_offset -= bytes_to_copy;
}

fclose(infile);
fclose(outfile);
free(moov_atom);

return 0;

error_out:
fclose(infile);
fclose(outfile);
free(moov_atom);
return 1;
}

Loading...