I've been trying to read some values out of the metadata of a .mov file (QuickTime File Format) with limited success. I've been using the following link as a reference:
I've managed to correctly locate and read out/calculate the media duration, but I can't seem to find which Atom the Bit Rate information is stored in. (Atoms are the internal blocks of metadata inside the file).
If anyone can point me to the correct Atom to read, I'll be alright reading it... I just can't seem to find it in the documentation even. "Bit Rate" is only mentioned a couple of times in the whole document.
UPDATE >>>
Going by the very limited information provided below by @szatmary, I have parsed the Sample Size Atom and the Time to Sample Atom from the relevant Track Atom, but am getting some bizarre values. For example, I keep getting a Sample Size value of 1
(when reading from multiple different single video .mov files with constant Bit Rates). The related documentation (from the above link) says:
Sample size
A 32-bit integer specifying the sample size. If all the samples are the same size, this field contains that size value. If this field is set to 0, then the samples have different sizes, and those sizes are stored in the sample size table.
So the field has the value of 1
, which means that all samples have the same size, and the Number of entries [in the Sample Size Table] field matches that of the Sample Count field in the single entry of the Time to Sample Table (some very large number). The documentation states this:
... if a video media has a constant frame rate, this table would have one entry and the count would be equal to the number of samples.
So the video has a constant Bit Rate. However, when reading the size entries from the Sample Size Table, they are all different and non-sensical... some are 0, while others are very large numbers up to around 40000. Why are they different if the video has a constant Bit Rate, or should I not be reading them in this case?
Another issue that I have found is that the single entry in the Time to Sample Table of the Time to Sample Atom has the following values:
Sample Count: some very large number (expected)
Sample Duration: 1
Unfortunately the documentation (from the above link) is very light here:
Time-to-sample table
A table that defines the duration of each sample in the media. Each table entry contains a count field and a duration field.
So what units do these 1
values use (Sample Duration & Sample Size)?
Any further help with calculating the correct Bit Rate would be greatly appreciated. Please note that I have been taking the Big-Endian-ness of the file into consideration and reversing the bytes of each field value before reading them.
UPDATE 2 >>>
I have managed to work out that the Sampling Rate is calculated like this:
Media Duration = Duration / Timescale (from the Movie Header Atom or Track Header Atom) Sampling Rate = Sample Count (from the Time-to-Sample Atom) / Media Duration
I just need to crack the Bit Rate now and further help is needed.