Comcast / scte35-js

A SCTE 35 Parser for JavaScript
https://comcast.github.io/scte35-js/
Apache License 2.0
47 stars 23 forks source link

Docs for splice insert #140

Closed samueleastdev closed 1 year ago

samueleastdev commented 1 year ago

Hi,

Do you have any docs on how to use spliceInsert?

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

Thanks

estobbart commented 1 year ago

Hi @samueleastdev just for some context, this module is just a parser of the data. So new SCTE35() is designed to be fed a message found within a stream. The splice_insert from SCTE35 is probably best explained by the specification. https://wagtail-prod-storage.s3.amazonaws.com/documents/SCTE_35_2022b.pdf I believe section 6.3 has the explanation of the usage, and 7.2 has the fields and data carried in the message.

samueleastdev commented 1 year ago

Ah ok thanks for highlighting that I was looking got a way to parse xml to binary.

<SCTE35>
  <SpliceInfoSection>
    <table_id>0xFC</table_id>
    <section_syntax_indicator>1</section_syntax_indicator>
    <private>1</private>
    <reserved>3</reserved>
    <section_length>8</section_length>
    <protocol_version>0</protocol_version>
    <encrypted_packet>0</encrypted_packet>
    <splice_command_type>5</splice_command_type>
    <descriptor_loop_length>0</descriptor_loop_length>
    <splice_insert>
      <splice_event_id>1234</splice_event_id>
      <splice_event_cancel_indicator>0</splice_event_cancel_indicator>
      <out_of_network_indicator>0</out_of_network_indicator>
      <program_splice_flag>1</program_splice_flag>
      <duration>30</duration>
      <splice_time>
        <time_specified_flag>1</time_specified_flag>
        <pts_time>10000000</pts_time>
      </splice_time>
    </splice_insert>
  </SpliceInfoSection>
</SCTE35>

And then insert into an mp4 with mp4box or ffmpeg.

ffmpeg -i input.mp4 -metadata service_provider=SPN -metadata service_name=SNN -f mpegts -mpegts_service_id 1 -mpegts_start_pid 0x100 -mpegts_pmt_start_pid 0x150 -mpegts_flags +eop -mpegts_copyts 0 -metadata service_type=1 -mpegts_audio_pids 0x101 -mpegts_video_pids 0x102 -mpegts_scte35_pid 0x1FF -mpegts_scte35 message.bin -c copy output.mp4
mp4box -inter 10000-40000 -add event.scte35 -isma file.mp4

I would then encode to dash and hls with AWS and was hoping media tailor would then pick it up for SSAI

I will read through the docs