Skip to content

Latest commit

 

History

History
177 lines (149 loc) · 5.72 KB

new2471.md

File metadata and controls

177 lines (149 loc) · 5.72 KB

New Features in threefive v2.4.71

sixfix

  • ffmpeg changes SCTE-35 streams types to 0x6 bin data. sixfix will convert the bin data back to SCTE-35.

  • The new file name is prefixed with 'fixed'.

  • As with all threefive, this works with local, http(s), UDP , and Multicast sources.

  • cli sixfix


  • Input file is sixed.ts
  a@fu:~/build/SCTE35_threefive$ ffprobe -hide_banner sixed.ts
[mpegts @ 0x55afc5641140] start time for stream 2 is not set in estimate_timings_from_pts
[mpegts @ 0x55afc5641140] start time for stream 3 is not set in estimate_timings_from_pts                                                                                                    
Input #0, mpegts, from 'sixed.ts':                                                                                                                                                           
  Duration: 00:04:56.30, start: 72668.995200, bitrate: 943 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
  Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, progressive), 640x360 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn
  Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 64 kb/s
  Stream #0:2[0x102]: Data: bin_data ([6][0][0][0] / 0x0006) <------ Bin Data
  Stream #0:3[0x103]: Data: timed_id3 (ID3  / 0x20334449)
  • Run sixfix
a@fu:~/build/SCTE35_threefive$ ./threefive sixfix sixed.ts
  • output file is named fixed-sixed.ts
a@fu:~/build/SCTE35_threefive$ ffprobe -hide_banner fixed-sixed.ts                            
Input #0, mpegts, from 'fixed-sixed.ts':                                                                                         
  Duration: 00:04:53.66, start: 72668.995200, bitrate: 944 kb/s
  Program 1 
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
  Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, progressive), 640x360 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn
  Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 48000 Hz, stereo, fltp, 64 kb/s
  Stream #0:2[0x102]: Data: scte_35       <------------ fixed
  Stream #0:3[0x103]: Data: timed_id3 (ID3  / 0x20334449)
  • code
    • you call one function with one arg, the mpegts to fix.
a@fu:~/build/SCTE35_threefive$ pypy3
Python 3.9.16 (7.3.11+dfsg-2+deb12u2, May 20 2024, 22:08:06)
[PyPy 7.3.11 with GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> from threefive.sixfix import sixfix
>>>> sixfix("sixed.ts")
fixing these pids {258}
Wrote: sixfixed-sixed.ts

xml

  • the cli tool now supports generating valid SCTE-35 xml output.
  • Input can be Base64, Hex or mpegts video.

  • cli
a@fu:~/build/SCTE35_threefive$ ./threefive xml   '/DBAAAGRZOeYAAAABQb+hJ8vqAAqAihDVUVJ/////3//AAAbX9ABFG1zbmJjX0VQMDQzMTEyMjEwNTU2EQEAbABeoQ==' 
<SpliceInfoSection xmlns="https://scte.org/schemas/35" ptsAdjustment="6734276504" protocolVersion="0" sapType="3" tier="0">
   <TimeSignal>
      <SpliceTime ptsTime="2225024936"/>
   </TimeSignal>
   <!-- Program End -->
   <SegmentationDescriptor segmentationEventId="4294967295" segmentationEventCancelIndicator="false" segmentationEventIdComplianceIndicator="true" segmentationTypeId="17" segmentNum="1" segmentsExpected="0" segmentationDuration="1794000">
      <!-- UPID: Deprecated -->
      <SegmentationUpid segmentationUpidType="1" segmentationUpidFormat="hexbinary">msnbc_EP043112210556</SegmentationUpid>
   </SegmentationDescriptor>
</SpliceInfoSection>
  • code
Python 3.9.16 (7.3.11+dfsg-2+deb12u2, May 20 2024, 22:08:06)
[PyPy 7.3.11 with GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> from threefive import Cue
>>>> data = '0xfc302500000000000000fff014050000013f7fefffffc3f680fe00a4cb80013f0000000063394f9c'
>>>> cue=Cue(data)
>>>> cue.decode()
True
>>>> print(cue.xml())
<SpliceInfoSection xmlns="https://scte.org/schemas/35" ptsAdjustment="0" protocolVersion="0" sapType="3" tier="4095">
   <SpliceInsert spliceEventId="319" spliceEventCancelIndicator="false" spliceImmediateFlag="false" eventIdComplianceFlag="true"
     availNum="0" availsExpected="0" outOfNetworkIndicator="true" uniqueProgramId="319">
      <Program>
         <SpliceTime ptsTime="8586000000"/>
      </Program>
      <BreakDuration autoReturn="true" duration="10800000"/>
   </SpliceInsert>
</SpliceInfoSection>

>>>> 
  • mpegts streams can be parsed and SCTE-35 output xml

  • cli
a@fu:~/build/SCTE35_threefive$ ./threefive-exp xml fixed-sixed.ts
  • code
    • Stream.decode accepts an optional function to be called every time a cue is found.
#!/usr/bin/env python3

import sys
from threefive import Stream,print2


def xml_out(cue):
    """
    xml_out print a Cue instance as xml
    """
    print2(cue.xml())


if __name__=='__main__':
    for arg in sys.argv[1:]:
        strm = Stream(arg)
        strm.decode(func=xml_out)

Loading and Encoding and Conversion

  • the threefive cli can load JSON, XML, Base64 or Hex and encode to JSON,XML,Base64,Hex,Int or Bytes

  • base64 to hex
  printf '/DBAAAGRZOeYAAAABQb+hJ8vqAAqAihDVUVJ/////3//AAAbX9ABFG1zbmJjX0VQMDQzMTEyMjEwNTU2EQEAbABeoQ==' |threefive encode hex
  • hex to base64
printf 0xfc302500000000000000fff014050000013f7fefffffc3f680fe00a4cb80013f0000000063394f9c|  threefive encode 
  • xml to base64
cat xml.xml | threefive encode
  • xml to hex
cat xml.xml | threefive encode hex
  • json to xml
cat json.json | threefive encode xml
  • xml to json
cat xml.xml | threefive encode json
  • xml to bytes
cat xml.xml | threefive encode bytes