Code Monkey home page Code Monkey logo

scte35-js's Introduction

ANSI/SCTE-35 JS

ANSI/SCTE35 JS PARSER

SCTE35 tools for parsing in CLI using NodeJS or in a "modern" browser.

Demo

Visit https://comcast.github.io/scte35-js/ and paste the following in the text box and hit the Parse button:

/DBGAAET8J+pAP/wBQb+AAAAAAAwAi5DVUVJQAErgX+/CR9TSUdOQUw6OGlTdzllUWlGVndBQUFBQUFBQUJCQT09NwMDaJ6RZQ==

In order to deploy changes to the demo read the README found at https://github.com/Comcast/scte35-js/tree/master/ui.

SCTE35 Module

// See ISCTE35 for methods & ISpliceInfoSection for results.
    import { SCTE35 } from "scte35";
    const scte35: SCTE35 = new SCTE35();
    const result = scte35.parseFromB64("<base64 string>");

CLI

The parser can be executed from the bin by first installing it globally and then executing the scte35 command:

    npm i scte35 -g
    scte35
    > ? Please provide the SCTE-35 tag that you would like to parse

Parsing defaults to base 64, however hexadecimal can easily be parsed as well using the --hex flag

    #default base64
    scte35 /DBGAAET8J+pAP/wBQb+AAAAAAAwAi5DVUVJQAErgX+/CR9TSUdOQUw6OGlTdzllUWlGVndBQUFBQUFBQUJCQT09NwMDaJ6RZQ==

    #hexadecimal
    scte35 --hex fc3046000113f09fa900fff00506fe000000000030022e4355454940012b817fbf091f5349474e414c3a386953773965516946567741414141414141414242413d3d370303689e9165

    #both will output the formatted JSON
    > {
        "tableId": 252,
        "selectionSyntaxIndicator": false,
        "privateIndicator": false,
        ...
    }

Piping

The parser output can be piped into other tools, such as a JSON display utility like fx in order to visualize the JSON object and interact with it.

    npm i -g fx
    scte35 /DBGAAET8J+pAP/wBQb+AAAAAAAwAi5DVUVJQAErgX+/CR9TSUdOQUw6OGlTdzllUWlGVndBQUFBQUFBQUJCQT09NwMDaJ6RZQ== | fx

scte35-js's People

Contributors

aflosada avatar avhetman avatar courtfinn avatar dependabot[bot] avatar estobbart avatar jdeisenh avatar johnriv avatar kristakhare avatar rosmaryg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scte35-js's Issues

Handle parse errors gracefully

Sometimes, a malformed base64 or hexadecimal string is provided as input. When this happens, an error like this can happen: UnhandledPromiseRejectionWarning: Error: Binary read error sectionLength: 2730 + 3 !== data.length: 15 at parseSCTE35Data

We need to either have some sort of validation here or maybe even a try catch block and output an error elucidating the reason we were not able to parse the string.

JavaScript Demo is broken - https://comcast.github.io/scte35-js/

JavaScript demo on github.io seems broken: https://comcast.github.io/scte35-js/.

If you enter the base64 encoded tag in the filed and click on 'Parse', an error is thrown in console:

main-es2015.64374c9c99d1d32d6085.js:1 ERROR ReferenceError: Buffer is not defined
    at M5tO.e.SCTE35.parseBase64 (main-es2015.64374c9c99d1d32d6085.js:1)
    at M5tO.e.SCTE35.parseFromB64 (main-es2015.64374c9c99d1d32d6085.js:1)
    at t.parse (main-es2015.64374c9c99d1d32d6085.js:1)
    at main-es2015.64374c9c99d1d32d6085.js:1
    at As (main-es2015.64374c9c99d1d32d6085.js:1)
    at r (main-es2015.64374c9c99d1d32d6085.js:1)
    at HTMLButtonElement.<anonymous> (main-es2015.64374c9c99d1d32d6085.js:1)
    at l.invokeTask (polyfills-es2015.1f913f16a2d346cc8bdc.js:1)
    at Object.onInvokeTask (main-es2015.64374c9c99d1d32d6085.js:1)
    at l.invokeTask (polyfills-es2015.1f913f16a2d346cc8bdc.js:1)

Bad read splice_insert: 16 expected: 20

When I parse this SCTE ("/DAlAAAAAAAAAP/wFAUAAqbVf+/+AAAAAH4AUmXAAAAAAAAAdIQsGg==") or any others from our stream, I get a parsed response from the library, but also get this error in the console:

Bad read splice_insert actual: 16 expected: 20
spliceInsert	@	scte35.js:111
parseSCTE35Data	@	scte35.js:166
push../node_modules/scte35/build/lib/scte35.js.SCTE35.parseFromB64	@	scte35.js:194

Running the same cue in the CLI on master, I get:

$ npm run parse "/DAlAAAAAAAAAP/wFAUAAqbVf+/+AAAAAH4AUmXAAAAAAAAAdIQsGg=="

> [email protected] parse C:\_libraries\scte35
> node ./scripts/cli.js "C:/Program Files/Git/DAlAAAAAAAAAP/wFAUAAqbVf+/+AAAAAH4AUmXAAAAAAAAAdIQsGg=="


C:\_libraries\scte35\lib\scte35.ts:284
        const splice = new DataView(bytes.buffer, offset, sis.spliceCommandLength);
                       ^
RangeError: Invalid DataView length undefined
    at new DataView (<anonymous>)
    at parseSCTE35Data (C:\_libraries\scte35\lib\scte35.ts:284:24)
    at Object.exports.SCTE35.parseFromB64 (C:\_libraries\scte35\lib\scte35.ts:322:12)
    at Object.<anonymous> (C:\_libraries\scte35\scripts\cli.js:22:42)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] parse: `node ./scripts/cli.js "C:/Program Files/Git/DAlAAAAAAAAAP/wFAUAAqbVf+/+AAAAAH4AUmXAAAAAAAAAdIQsGg=="`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] parse script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nils\AppData\Roaming\npm-cache\_logs\2019-05-23T16_35_58_717Z-debug.log

I also tried on the splice-descriptors branch and got this error:

$ npm run parse "/DAlAAAAAAAAAP/wFAUAAqbVf+/+AAAAAH4AUmXAAAAAAAAAdIQsGg=="

> [email protected] parse C:\_libraries\scte35
> node ./scripts/cli.js "C:/Program Files/Git/DAlAAAAAAAAAP/wFAUAAqbVf+/+AAAAAH4                                                                                                                                  AUmXAAAAAAAAAdIQsGg=="


C:\_libraries\scte35\lib\scte35.ts:266
        throw new Error(`Binary read error sectionLength: ${sis.sectionLength} +                                                                                                                                   3 !== data.length: ${bytes.byteLength}`);
              ^
Error: Binary read error sectionLength: 1003 + 3 !== data.length: 54
    at parseSCTE35Data (C:\_libraries\scte35\lib\scte35.ts:266:15)
    at Object.exports.SCTE35.parseFromB64 (C:\_libraries\scte35\lib\scte35.ts:34                                                                                                                                  4:12)
    at Object.<anonymous> (C:\_libraries\scte35\scripts\cli.js:22:35)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] parse: `node ./scripts/cli.js "C:/Program Files/Git/DAlAAA                                                                                                                                  AAAAAAP/wFAUAAqbVf+/+AAAAAH4AUmXAAAAAAAAAdIQsGg=="`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] parse script.
npm ERR! This is probably not a problem with npm. There is likely additional log                                                                                                                                  ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Nils\AppData\Roaming\npm-cache\_logs\2019-05-23T16_35_15_6                                                                                                                                  29Z-debug.log

Docs for splice insert

Hi,

Do you have any docs on how to use spliceInsert?

import { SCTE35 } from "scte35";
const scte35 = new SCTE35();
const result = scte35.spliceInsert();

Thanks

Demo Page down due to CORS

It appears that our demo page is currently down. Until now we have been hosting the UI filed directly on GitHub, I am not sure that this is possible anymore.
We will need to figure out if we can fix this or find a new place to host the app.

SCTE 35 is parsing errors

I tried parsing a SCTE 35 signal on the web site, and it's giving me much different information than other SCTE 35 parsers.

I tried this signal:

/DAxAAAAAAAAAP/wFAUAAAD5f+//vbeKtH4AUmNiAAAAAAAMAQpDVUVJUJ8xMjEqiKYAKA==

What this library reported:

{
	"tableId": 252,
	"selectionSyntaxIndicator": false,
	"privateIndicator": false,
	"sectionLength": 49,
	"protocolVersion": 0,
	"encryptedPacket": false,
	"encryptedAlgorithm": 0,
	"ptsAdjustment": 0,
	"cwIndex": 0,
	"tier": 4095,
	"spliceCommandLength": 20,
	"spliceCommandType": 5,
	"spliceCommand": {
		"spliceEventId": 249,
		"spliceEventCancelIndicator": false,
		"outOfNetworkIndicator": true,
		"programSpliceFlag": true,
		"durationFlag": true,
		"spliceImmediateFlag": false,
		"spliceTime": {
			"specified": false
		},
		"breakDuration": {
			"autoReturn": true,
			"duration": 7374287998
		},
		"uniqueProgramId": 82,
		"available": 99,
		"expected": 98
	},
	"descriptorLoopLength": 12,
	"descriptor": [
		{
			"spliceDescriptorTag": 1,
			"descriptorLength": 10,
			"indentifier": "CUEI"
		}
	],
	"crc": 2292580392
}

What other SCTE 35 tools report:

splice_info_section() {
    table_id: 0x00fc (252)
    section_syntax_indicator: 0
    private_indicator: 0
    section_length: 0x31 (49 bytes)
}
protocol_version: 0x00 (0)
encrypted_packet: false
encryption_algorithm: 0x00 (No encryption)
pts_adjustment: 0x000000000 (0 ticks, 0.000 secs)
cw_index: 0x00 (0)
tier: 0xfff (4095)
splice_command_length: 0x014 (20 bytes)
splice_command_type: 0x05
splice_insert() {
    splice_event_id: 0x00f9 (249)
    splice_event_cancel_indicator: false
    out_of_network_indicator: true
    program_splice_flag: true
    duration_flag: true
    splice_immediate_flag: false
    time_specified_flag: true
    pts_time: 0x1bdb78ab4 (7477889716 ticks, 83087.664 secs)
    auto_return: false
    duration: 0x526362 (5399394 ticks, 59.000000 secs)
    unique_program_id: 0x0000 (0)
    avail_num: 0x00 (0)
    avails_expected: 0x00 (0)
}
descriptor_loop_length: 0x000c (12 bytes)
dtmf_descriptor() {
    splice_descriptor_tag: 0x01 (1)
    descriptor_length: 0x0a (10 bytes)
    identifier: 0x43554549 (1129661769 CUEI)
    preroll: 0x50 (80/10 s)
    dtmf_count: 0x4 (4 chars)
    dtmf_chars: 121*
}

Splice time is specified, but this library says it's not. Break duration in this library is wrong. Program ID is wrong. Avails are all wrong.

Package configuration for import

The package.json has incorrect main property or index.js file is missing, thus it is not possible to import module using npm.

Also types declaration is missing in package.json.

[Minor]Logo/Icon image breaks on Top left corner

Description :
Icon image present in top let corner breaks and not displayed.

Steps to reproduce :

  • Open the URL in chrome/Firefox browser
  • Observe the icon in the top left corner of the page.

Expected result :
Icon should be displayed on top left corner.

Actual Result :
Icon not displayed on top left corner.

Attachment :
Image
Screenshot 2023-12-05 at 5 20 32 PM

Cannot install npm (case sensitive issues)

Guys, I am using latest version (2.10).
Package.json
"main": "build/SCTE35.js", but in build folder the file is "scte35.js". In windows that will work however in Linux env I had to rename it

Mapping of segmentation descriptor.segmentation_type_id codes to strings

Hey guys,

With the following Base64 encoded marker: /DAsAAAAAAAAAP/wBQb/pczlxQAWAhRDVUVJBY9cfn//AACYb3AOADAAABf3WQg=

I noticed that when using this tool to parse the marker I see:

segmentation_type_id: "ProviderAdvertisementStart",

whereas with this parser I get:

segmentationTypeId: 48

It would be nice to have such a feature in the scte35-js parser as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.