How to use imsc - 3 common examples

To help you get started, we’ve selected a few imsc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Dash-Industry-Forum / dash.js / src / streaming / text / TextTracks.js View on Github external
function renderCaption(cue) {
        if (captionContainer) {
            const finalCue = document.createElement('div');
            captionContainer.appendChild(finalCue);
            previousISDState = renderHTML(cue.isd, finalCue, function (uri) {
                const imsc1ImgUrnTester = /^(urn:)(mpeg:[a-z0-9][a-z0-9-]{0,31}:)(subs:)([0-9]+)$/;
                const smpteImgUrnTester = /^#(.*)$/;
                if (imsc1ImgUrnTester.test(uri)) {
                    const match = imsc1ImgUrnTester.exec(uri);
                    const imageId = parseInt(match[4], 10) - 1;
                    const imageData = btoa(cue.images[imageId]);
                    const dataUrl = 'data:image/png;base64,' + imageData;
                    return dataUrl;
                } else if (smpteImgUrnTester.test(uri)) {
                    const match = smpteImgUrnTester.exec(uri);
                    const imageId = match[1];
                    const dataUrl = 'data:image/png;base64,' + cue.embeddedImages[imageId];
                    return dataUrl;
                } else {
                    return null;
                }
github Dash-Industry-Forum / dash.js / src / streaming / utils / TTMLParser.js View on Github external
if (currentImageId) {
                    accumulated_image_data = accumulated_image_data + contents;
                }
            }
        };

        if (!data) {
            errorMsg = 'no ttml data to parse';
            throw new Error(errorMsg);
        }

        content.data = data;

        eventBus.trigger(Events.TTML_TO_PARSE, content);

        const imsc1doc = fromXML(content.data, function (msg) {
            errorMsg = msg;
        }, metadataHandler);

        eventBus.trigger(Events.TTML_PARSED, {ttmlString: content.data, ttmlDoc: imsc1doc});

        const mediaTimeEvents = imsc1doc.getMediaTimeEvents();

        for (i = 0; i < mediaTimeEvents.length; i++) {
            let isd = generateISD(imsc1doc, mediaTimeEvents[i], function (error) {
                errorMsg = error;
            });

            if (isd.contents.some(topLevelContents => topLevelContents.contents.length)) {
                //be sure that mediaTimeEvents values are in the mp4 segment time ranges.
                startTime = (mediaTimeEvents[i] + offsetTime) < startTimeSegment ? startTimeSegment : (mediaTimeEvents[i] + offsetTime);
                endTime = (mediaTimeEvents[i + 1] + offsetTime) > endTimeSegment ? endTimeSegment : (mediaTimeEvents[i + 1] + offsetTime);
github Dash-Industry-Forum / dash.js / src / streaming / utils / TTMLParser.js View on Github external
}

        content.data = data;

        eventBus.trigger(Events.TTML_TO_PARSE, content);

        const imsc1doc = fromXML(content.data, function (msg) {
            errorMsg = msg;
        }, metadataHandler);

        eventBus.trigger(Events.TTML_PARSED, {ttmlString: content.data, ttmlDoc: imsc1doc});

        const mediaTimeEvents = imsc1doc.getMediaTimeEvents();

        for (i = 0; i < mediaTimeEvents.length; i++) {
            let isd = generateISD(imsc1doc, mediaTimeEvents[i], function (error) {
                errorMsg = error;
            });

            if (isd.contents.some(topLevelContents => topLevelContents.contents.length)) {
                //be sure that mediaTimeEvents values are in the mp4 segment time ranges.
                startTime = (mediaTimeEvents[i] + offsetTime) < startTimeSegment ? startTimeSegment : (mediaTimeEvents[i] + offsetTime);
                endTime = (mediaTimeEvents[i + 1] + offsetTime) > endTimeSegment ? endTimeSegment : (mediaTimeEvents[i + 1] + offsetTime);

                if (startTime < endTime) {
                    captionArray.push({
                        start: startTime,
                        end: endTime,
                        type: 'html',
                        cueID: getCueID(),
                        isd: isd,
                        images: images,

imsc

Renders IMSC documents to HTML5 fragments

BSD-2-Clause
Latest version published 3 months ago

Package Health Score

69 / 100
Full package analysis