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
92b03b90
authored
2014-09-25 15:38:25 -0700
by
Simeon Bateman
Committed by
David LaPalomento
2015-07-31 16:40:38 -0400
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
setup the generator to separate audio and video init files.
1 parent
a545f184
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
15 deletions
src/mp4-generator.js
test/mp4-generator_test.js
src/mp4-generator.js
View file @
92b03b9
...
...
@@ -2,7 +2,7 @@
'use strict'
;
var
box
,
dinf
,
ftyp
,
minf
,
moof
,
moov
,
mvex
,
mvhd
,
trak
,
tkhd
,
mdia
,
mdhd
,
hdlr
,
stbl
,
stsd
,
types
,
MAJOR_BRAND
,
MINOR_VERSION
,
VIDEO_HDLR
,
VMHD
,
DREF
,
STCO
,
STSC
,
STSZ
,
STTS
,
TREX
,
stsd
,
styp
,
types
,
MAJOR_BRAND
,
MINOR_VERSION
,
VIDEO_HDLR
,
AUDIO_HDLR
,
HDLR_TYPES
,
VMHD
,
DREF
,
STCO
,
STSC
,
STSZ
,
STTS
,
TREX
,
Uint8Array
,
DataView
;
Uint8Array
=
window
.
Uint8Array
;
...
...
@@ -72,7 +72,7 @@ DataView = window.DataView;
0x6f
,
0x48
,
0x61
,
0x6e
,
0x64
,
0x6c
,
0x65
,
0x72
,
0x00
// name: 'VideoHandler'
]);
SOUND
_HDLR
=
new
Uint8Array
([
AUDIO
_HDLR
=
new
Uint8Array
([
0x00
,
// version 0
0x00
,
0x00
,
0x00
,
// flags
0x00
,
0x00
,
0x00
,
0x00
,
// pre_defined
...
...
@@ -80,10 +80,14 @@ DataView = window.DataView;
0x00
,
0x00
,
0x00
,
0x00
,
// reserved
0x00
,
0x00
,
0x00
,
0x00
,
// reserved
0x00
,
0x00
,
0x00
,
0x00
,
// reserved
0x5
6
,
0x69
,
0x64
,
0x65
,
0x6
f
,
0x48
,
0x61
,
0x6e
,
0x
73
,
0x6f
,
0x75
,
0x6e
,
0x00
// name: 'Video
Handler'
0x5
3
,
0x6f
,
0x75
,
0x6e
,
0x6
4
,
0x48
,
0x61
,
0x6e
,
0x
64
,
0x6c
,
0x65
,
0x72
,
0x00
// name: 'Sound
Handler'
]);
HDLR_TYPES
=
{
"video"
:
VIDEO_HDLR
,
"audio"
:
AUDIO_HDLR
};
DREF
=
new
Uint8Array
([
0x00
,
// version 0
0x00
,
0x00
,
0x00
,
// flags
...
...
@@ -158,8 +162,8 @@ ftyp = function() {
return
box
(
types
.
ftyp
,
MAJOR_BRAND
,
MINOR_VERSION
,
MAJOR_BRAND
);
};
hdlr
=
function
()
{
return
box
(
types
.
hdlr
,
VIDEO_HDLR
);
hdlr
=
function
(
type
)
{
return
box
(
types
.
hdlr
,
HDLR_TYPES
[
type
]
);
};
mdhd
=
function
(
duration
)
{
return
box
(
types
.
mdhd
,
new
Uint8Array
([
...
...
@@ -177,8 +181,8 @@ mdhd = function(duration) {
0x00
,
0x00
]));
};
mdia
=
function
(
duration
,
width
,
height
)
{
return
box
(
types
.
mdia
,
mdhd
(
duration
),
hdlr
(),
minf
(
width
,
height
));
mdia
=
function
(
duration
,
width
,
height
,
type
)
{
return
box
(
types
.
mdia
,
mdhd
(
duration
),
hdlr
(
type
),
minf
(
width
,
height
));
};
minf
=
function
(
width
,
height
)
{
return
box
(
types
.
minf
,
box
(
types
.
vmhd
,
VMHD
),
dinf
(),
stbl
(
width
,
height
));
...
...
@@ -203,8 +207,8 @@ moof = function(tracks) {
box
(
types
.
mfhd
),
box
.
apply
(
null
,
trafCall
));
};
moov
=
function
(
duration
,
width
,
height
)
{
return
box
(
types
.
moov
,
mvhd
(
duration
),
trak
(
duration
,
width
,
height
),
mvex
());
moov
=
function
(
duration
,
width
,
height
,
type
)
{
return
box
(
types
.
moov
,
mvhd
(
duration
),
trak
(
duration
,
width
,
height
,
type
),
mvex
());
};
mvex
=
function
()
{
return
box
(
types
.
mvex
,
box
(
types
.
trex
,
TREX
));
...
...
@@ -349,8 +353,8 @@ tkhd = function(duration, width, height) {
]));
};
trak
=
function
(
duration
,
width
,
height
)
{
return
box
(
types
.
trak
,
tkhd
(
duration
,
width
,
height
),
mdia
(
duration
,
width
,
height
));
trak
=
function
(
duration
,
width
,
height
,
type
)
{
return
box
(
types
.
trak
,
tkhd
(
duration
,
width
,
height
),
mdia
(
duration
,
width
,
height
,
type
));
};
window
.
videojs
.
mp4
=
{
...
...
@@ -360,7 +364,7 @@ window.videojs.mp4 = {
initSegment
:
function
()
{
var
fileType
=
ftyp
(),
movie
=
moov
(
0xffffffff
,
1280
,
720
),
movie
=
moov
(
0xffffffff
,
1280
,
720
,
"video"
),
result
=
new
Uint8Array
(
fileType
.
byteLength
+
movie
.
byteLength
);
result
.
set
(
fileType
);
...
...
test/mp4-generator_test.js
View file @
92b03b9
...
...
@@ -41,7 +41,7 @@ test('generates a BSMFF ftyp', function() {
test
(
'generates a moov'
,
function
()
{
var
boxes
,
mvhd
,
tkhd
,
mdhd
,
hdlr
,
minf
,
mvex
,
data
=
mp4
.
moov
(
100
,
600
,
300
);
data
=
mp4
.
moov
(
100
,
600
,
300
,
"video"
);
ok
(
data
,
'box is not null'
);
...
...
@@ -204,6 +204,34 @@ test('generates a moov', function() {
},
mvex
,
'writes a movie extends box'
);
});
test
(
'generates a sound hdlr'
,
function
()
{
var
boxes
,
hdlr
,
data
=
mp4
.
moov
(
100
,
600
,
300
,
"audio"
);
ok
(
data
,
'box is not null'
);
boxes
=
inspectMp4
(
data
);
hdlr
=
boxes
[
0
].
boxes
[
1
].
boxes
[
1
].
boxes
[
1
];
equal
(
hdlr
.
type
,
'hdlr'
,
'generate an hdlr type'
);
equal
(
hdlr
.
handlerType
,
'soun'
,
'wrote a sound handler'
);
equal
(
hdlr
.
name
,
'SoundHandler'
,
'wrote the handler name'
);
});
test
(
'generates a video hdlr'
,
function
()
{
var
boxes
,
hdlr
,
data
=
mp4
.
moov
(
100
,
600
,
300
,
"video"
);
ok
(
data
,
'box is not null'
);
boxes
=
inspectMp4
(
data
);
hdlr
=
boxes
[
0
].
boxes
[
1
].
boxes
[
1
].
boxes
[
1
];
equal
(
hdlr
.
type
,
'hdlr'
,
'generate an hdlr type'
);
equal
(
hdlr
.
handlerType
,
'vide'
,
'wrote a video handler'
);
equal
(
hdlr
.
name
,
'VideoHandler'
,
'wrote the handler name'
);
});
test
(
'generates an initialization segment'
,
function
()
{
var
data
=
mp4
.
initSegment
(),
...
...
Please
register
or
sign in
to post a comment