Jump to content

TransportStream Analyzer / Utility Tool


Recommended Posts

mickle026
Posted (edited)

My first release, so might not be perfect.

Its a command line tool for windows x64, built in net8, build compiled as a complete stand alone, so shouldn't need you to have net runtimes.

-----------------------------------------------------------
Transport Stream Analyzer by Mike Williams - Copyright 2025
-----------------------------------------------------------

Usage: TransportStreamAnalyzer <file_path> [options]
Options:
  -extractpid <pid>                 Extracts a single PID to a new file.
  -extractprogram longest          Extracts the program with the longest elementary stream.
  -extractpids <pid1>,<pid2>,...    Extracts a comma-separated list of PIDs.
  -extractsegment <start_mm:ss>-<end_mm:ss> Extracts a time segment from the stream.
  -join <file1>,<file2>,... -output <output_file> Joins multiple TS files into one.
  -pmtpid <pid>                     Manually specifies the PMT PID for program extraction.
  -same-dir                         Saves the output file in the same directory as the input file.
  -packet-range <start>-<end>       Extracts a segment of packets by index.

Examples:
  Analyze a file and display stats: TransportStreamAnalyzer input.ts
  Extract a single PID: TransportStreamAnalyzer input.ts -extractpid 257
  Extract multiple PIDs: TransportStreamAnalyzer input.ts -extractpids 257,258,259
  Extract a time segment: TransportStreamAnalyzer video.ts -extractsegment 01:30-02:00
  Extract a packet range: TransportStreamAnalyzer video.ts -packet-range 10000-50000
  Extract the longest program: TransportStreamAnalyzer stream.ts -extractprogram longest
  Join multiple files: TransportStreamAnalyzer -join part1.ts,part2.ts,part3.ts -output joined.ts
  Extract with a custom output directory: TransportStreamAnalyzer input.ts -extractpid 257 -same-dir
  Specify PMT PID: TransportStreamAnalyzer input.ts -extractprogram longest -pmtpid 4097

X:\TVRecordrings\TV_Shows\Cheers (1982)\Season 1>TransportStreamAnalyzer.exe "Cheers S01E02 Sam's Women.ts"

--- Transport Stream File: 'Cheers S01E02 Sam's Women.ts' ---
Total Packets to Read: 2227544
Packet Size: 188 bytes

Starting analysis...
Progress: 100.00% | 2227544 / 2227544 packets
Warning: File size is not a multiple of 188. Last 76 bytes were not processed.
Progress: 100.00% | 2227544 / 2227544 packets


--- Starting In-Memory Analysis ---
  -> Parsing PAT and PMT tables...
  -> Parsing PAT sections from PID 0 (repeated entries suppressed)...
      -> Found new PAT (Version: 0)
      -> Found PAT entry: Program Number = 8384, PMT PID = 1100

  -> Parsing PMT sections (repeated entries suppressed)...
    -> Found PMT on PID 1100 for Program 8384 (Version: 1)
      -> Found Elementary Stream: PID = 1101, Stream Type = MPEG-2 Video
      -> Found Elementary Stream: PID = 1102, Stream Type = MPEG-2 Audio
      -> Found Elementary Stream: PID = 1103, Stream Type = MPEG-2 Audio
      -> Found Elementary Stream: PID = 1131, Stream Type = PES private data/AC-3
      -> Found Elementary Stream: PID = 1135, Stream Type = AC-4
      -> Found Elementary Stream: PID = 3001, Stream Type = Unknown (0x05)
Done.
  -> Grouping and analyzing packet data...
      Progress: 100.00%

  -> Generating formatted report...

--- Transport Stream Analysis for 'Cheers S01E02 Sam's Women.ts' ---
Total Packets Found: 2227544
Packet Size: 188 bytes

PID        Packet Count    Payload Start        Continuity Errors    Is PAT     Is PMT     Stream Type
------------------------------------------------------------------------------------------------------------------------
0          16774           Yes                  None                 Yes        No         N/A
1100       16775           Yes                  None                 No         Yes        N/A
1101       1877671         Yes                  None                 No         No         MPEG-2 Video
1102       225215          Yes                  None                 No         No         MPEG-2 Audio
1103       77660           Yes                  None                 No         No         MPEG-2 Audio
1131       9962            Yes                  None                 No         No         PES private data/AC-3
1135       1613            Yes                  None                 No         No         AC-4
3001       1874            Yes                  None                 No         No         Unknown (0x05)

 

For recordings.

TransportStreamAnalyzer.exe stream.ts -extractprogram longest -same-dir


Will extract a playable ts file and remove everything that's not got the same program identifier.  ie, it will remove most of the adverts and other programs from the start or end of the ts file, but may not remove them all if some have the same pid. 

 

Have a play :), but remember its all  at your own risk, so play with copies or backups first!

Only tested on my own files recorded from HDHomeRun which uses a lot of the same pids, so not as good as satellite receivers, that tend to use different pids for different programs.

 

 

TransportStreamAnalyzer.exe

Edited by mickle026
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...