Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
videojs-contrib-hls
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
aeaa8493
authored
2014-12-01 10:57:29 -0500
by
David LaPalomento
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
WIP: calculating data offsets in the trun
1 parent
e6559cce
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
5 deletions
src/mp4-generator.js
test/mp4-generator_test.js
test/transmuxer_test.js
src/mp4-generator.js
View file @
aeaa849
...
...
@@ -422,6 +422,7 @@ tkhd = function(track) {
};
traf
=
function
(
track
)
{
var
sampleDependencyTable
=
sdtp
(
track
);
return
box
(
types
.
traf
,
box
(
types
.
tfhd
,
new
Uint8Array
([
0x00
,
// version 0
...
...
@@ -436,8 +437,15 @@ traf = function(track) {
0x00
,
0x00
,
0x00
,
// flags
0x00
,
0x00
,
0x00
,
0x00
// baseMediaDecodeTime
])),
trun
(
track
),
sdtp
(
track
));
trun
(
track
,
sdtp
.
length
+
16
+
// tfhd
16
+
// tfdt
8
+
// traf header
16
+
// mfhd
8
+
// moof header
8
),
// mdat header
sampleDependencyTable
);
};
/**
...
...
@@ -467,10 +475,11 @@ trex = function(track) {
]));
};
trun
=
function
(
track
)
{
trun
=
function
(
track
,
offset
)
{
var
bytes
,
samples
,
sample
,
i
;
samples
=
track
.
samples
||
[];
offset
+=
8
+
12
+
(
16
*
samples
.
length
);
bytes
=
[
0x00
,
// version 0
...
...
@@ -479,7 +488,10 @@ trun = function(track) {
(
samples
.
length
&
0xFF0000
)
>>>
16
,
(
samples
.
length
&
0xFF00
)
>>>
8
,
samples
.
length
&
0xFF
,
// sample_count
0x00
,
0x00
,
0x00
,
0x00
// data_offset
(
offset
&
0xFF000000
)
>>>
24
,
(
offset
&
0xFF0000
)
>>>
16
,
(
offset
&
0xFF00
)
>>>
8
,
offset
&
0xFF
// data_offset
];
for
(
i
=
0
;
i
<
samples
.
length
;
i
++
)
{
...
...
@@ -503,7 +515,7 @@ trun = function(track) {
(
sample
.
compositionTimeOffset
&
0xFF000000
)
>>>
24
,
(
sample
.
compositionTimeOffset
&
0xFF0000
)
>>>
16
,
(
sample
.
compositionTimeOffset
&
0xFF00
)
>>>
8
,
sample
.
compositionTimeOffset
&
0xFF
,
// sample_composition_time_offset
sample
.
compositionTimeOffset
&
0xFF
// sample_composition_time_offset
]);
}
return
box
(
types
.
trun
,
new
Uint8Array
(
bytes
));
...
...
test/mp4-generator_test.js
View file @
aeaa849
...
...
@@ -353,6 +353,7 @@ test('generates a minimal moof', function() {
equal
(
trun
.
type
,
'trun'
,
'generated a trun box'
);
equal
(
typeof
trun
.
dataOffset
,
'number'
,
'has a data offset'
);
ok
(
trun
.
dataOffset
>=
0
,
'has a non-negative data offset'
);
equal
(
trun
.
dataOffset
,
moof
[
0
].
size
+
8
,
'sets the data offset past the mdat header'
);
equal
(
trun
.
samples
.
length
,
2
,
'wrote two samples'
);
equal
(
trun
.
samples
[
0
].
duration
,
9000
,
'wrote a sample duration'
);
...
...
test/transmuxer_test.js
View file @
aeaa849
...
...
@@ -888,6 +888,12 @@ validateTrackFragment = function(track, metadata) {
trun
=
track
.
boxes
[
2
];
ok
(
trun
.
dataOffset
>=
0
,
'set data offset'
);
equal
(
trun
.
dataOffset
,
trun
.
size
+
16
+
// mfhd size
8
+
// moof header size
8
,
// mdat header size
'uses movie fragment relative addressing'
);
ok
(
trun
.
samples
.
length
>
0
,
'generated media samples'
);
for
(
i
=
0
;
i
<
trun
.
samples
.
length
;
i
++
)
{
sample
=
trun
.
samples
[
i
];
...
...
Please
register
or
sign in
to post a comment