Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for parsing manifests with webm segments. #79

Merged
merged 2 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/toM3u8.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,9 @@ export const toM3u8 = (dashPlaylists, sidxMapping = {}) => {
} = dashPlaylists[0].attributes;

const videoOnly = ({ attributes }) =>
attributes.mimeType === 'video/mp4' || attributes.contentType === 'video';
attributes.mimeType === 'video/mp4' || attributes.mimeType === 'video/webm' || attributes.contentType === 'video';
const audioOnly = ({ attributes }) =>
attributes.mimeType === 'audio/mp4' || attributes.contentType === 'audio';
attributes.mimeType === 'audio/mp4' || attributes.mimeType === 'audio/webm' || attributes.contentType === 'audio';
const vttOnly = ({ attributes }) =>
attributes.mimeType === 'text/vtt' || attributes.contentType === 'text';

Expand Down
8 changes: 8 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import maatVttSegmentTemplate from './manifests/maat_vtt_segmentTemplate.mpd';
import segmentBaseTemplate from './manifests/segmentBase.mpd';
import segmentListTemplate from './manifests/segmentList.mpd';
import multiperiod from './manifests/multiperiod.mpd';
import webmsegments from './manifests/webmsegments.mpd';
import multiperiodDynamic from './manifests/multiperiod-dynamic.mpd';
import {
parsedManifest as maatVttSegmentTemplateManifest
Expand All @@ -19,6 +20,9 @@ import {
import {
parsedManifest as multiperiodManifest
} from './manifests/multiperiod.js';
import {
parsedManifest as webmsegmentsManifest
} from './manifests/webmsegments.js';
import {
parsedManifest as multiperiodDynamicManifest
} from './manifests/multiperiod-dynamic.js';
Expand Down Expand Up @@ -49,6 +53,10 @@ QUnit.test('has parse', function(assert) {
name: 'multiperiod',
input: multiperiod,
expected: multiperiodManifest
}, {
name: 'webmsegments',
input: webmsegments,
expected: webmsegmentsManifest
}, {
name: 'multiperiod_dynamic',
input: multiperiodDynamic,
Expand Down
154 changes: 154 additions & 0 deletions test/manifests/webmsegments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
export const parsedManifest = {
allowCache: true,
discontinuityStarts: [],
segments: [],
endList: true,
mediaGroups: {
'AUDIO': {
audio: {
en: {
language: 'en',
autoselect: true,
default: true,
playlists: [
{
attributes: {
'NAME': '2',
'BANDWIDTH': 32000,
'CODECS': 'opus',
'PROGRAM-ID': 1
},
uri: '',
endList: true,
timeline: 1,
resolvedUri: '',
targetDuration: 4,
segments: [
{
uri: 'audio/segment_0.chk',
timeline: 1,
duration: 4,
resolvedUri: 'https://www.example.com/audio/segment_0.chk',
map: {
uri: 'audio/init.hdr',
resolvedUri: 'https://www.example.com/audio/init.hdr'
},
number: 0
},
{
uri: 'audio/segment_1.chk',
timeline: 1,
duration: 4,
resolvedUri: 'https://www.example.com/audio/segment_1.chk',
map: {
uri: 'audio/init.hdr',
resolvedUri: 'https://www.example.com/audio/init.hdr'
},
number: 1
},
{
uri: 'audio/segment_2.chk',
timeline: 1,
duration: 4,
resolvedUri: 'https://www.example.com/audio/segment_2.chk',
map: {
uri: 'audio/init.hdr',
resolvedUri: 'https://www.example.com/audio/init.hdr'
},
number: 2
},
{
uri: 'audio/segment_3.chk',
timeline: 1,
duration: 4,
resolvedUri: 'https://www.example.com/audio/segment_3.chk',
map: {
uri: 'audio/init.hdr',
resolvedUri: 'https://www.example.com/audio/init.hdr'
},
number: 3
}
],
mediaSequence: 0
}
],
uri: ''
}
}
},
'VIDEO': {},
'CLOSED-CAPTIONS': {},
'SUBTITLES': {}
},
uri: '',
duration: 16,
playlists: [
{
attributes: {
'NAME': '1',
'AUDIO': 'audio',
'SUBTITLES': 'subs',
'RESOLUTION': {
width: 480,
height: 200
},
'CODECS': 'av1',
'BANDWIDTH': 100000,
'PROGRAM-ID': 1
},
uri: '',
endList: true,
timeline: 1,
resolvedUri: '',
targetDuration: 4,
segments: [
{
uri: 'video/segment_0.chk',
timeline: 1,
duration: 4,
resolvedUri: 'https://www.example.com/video/segment_0.chk',
map: {
uri: 'video/init.hdr',
resolvedUri: 'https://www.example.com/video/init.hdr'
},
number: 0
},
{
uri: 'video/segment_1.chk',
timeline: 1,
duration: 4,
resolvedUri: 'https://www.example.com/video/segment_1.chk',
map: {
uri: 'video/init.hdr',
resolvedUri: 'https://www.example.com/video/init.hdr'
},
number: 1
},
{
uri: 'video/segment_2.chk',
timeline: 1,
duration: 4,
resolvedUri: 'https://www.example.com/video/segment_2.chk',
map: {
uri: 'video/init.hdr',
resolvedUri: 'https://www.example.com/video/init.hdr'
},
number: 2
},
{
uri: 'video/segment_3.chk',
timeline: 1,
duration: 4,
resolvedUri: 'https://www.example.com/video/segment_3.chk',
map: {
uri: 'video/init.hdr',
resolvedUri: 'https://www.example.com/video/init.hdr'
},
number: 3
}
],
mediaSequence: 0
}
],
minimumUpdatePeriod: 0
};
21 changes: 21 additions & 0 deletions test/manifests/webmsegments.mpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MPD id="a467fa27-2820-41d1-89e2-a43216770daa" profiles="urn:mpeg:dash:profile:full:2011" type="static"
mediaPresentationDuration="P0Y0M0DT0H0M16S" minBufferTime="P0Y0M0DT0H0M2.000S"
xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:ns2="http://www.w3.org/1999/xlink">
<Period id="1" start="P0Y0M0DT0H0M0.000S">
<BaseURL>https://www.example.com/base</BaseURL>
<AdaptationSet mimeType="video/webm">
<Representation id="1" bandwidth="100000" width="480" height="200" frameRate="24" codecs="av1">
<SegmentTemplate media="video/segment_$Number$.chk" initialization="video/init.hdr" duration="96000"
startNumber="0" timescale="24000"/>
</Representation>
</AdaptationSet>
<AdaptationSet lang="en" mimeType="audio/webm">
<AudioChannelConfiguration schemeIdUri="urn:mpeg:dash:23003:3:audio_channel_configuration:2011" value="2"/>
<Representation id="2" bandwidth="32000" audioSamplingRate="48000" codecs="opus">
<SegmentTemplate media="audio/segment_$Number$.chk" initialization="audio/init.hdr" duration="192000"
startNumber="0" timescale="48000"/>
</Representation>
</AdaptationSet>
</Period>
</MPD>