Skip to content

Commit

Permalink
feat: recognize webm segments as video (videojs#79)
Browse files Browse the repository at this point in the history
Co-authored-by: Gary Katsevman <git@gkatsev.com>
  • Loading branch information
2 people authored and RomeroDiver committed Dec 7, 2020
1 parent 4e665bc commit 49b323b
Show file tree
Hide file tree
Showing 4 changed files with 185 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/toM3u8.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ export const toM3u8 = (dashPlaylists, locations, 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 @@ -11,6 +11,7 @@ import segmentListTemplate from './manifests/segmentList.mpd';
import locationTemplate from './manifests/location.mpd';
import locationsTemplate from './manifests/locations.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 @@ -24,6 +25,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 @@ -64,6 +68,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>

0 comments on commit 49b323b

Please sign in to comment.