asticode / go-astits

Demux and mux MPEG Transport Streams (.ts) natively in GO

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement ATSC standard as well

a2geek opened this issue · comments

I'm trying to read the program listings from the channel data stream from a HDHomerun. For now, I'm just using curl to pull from the device into a file.
I am taking the sample app and just reporting on any EIT packets. My app finds none. If I use dvbtee to dump out data, I definitely get schedule listings from the same file.
Looking for some guidance around retrieving the program listings. Is the EIT packet the correct one? Is that something that the library supports? (The checkbox indicates it should...)

Thanks!

Did you tune pid 0x12 to capture EIT stream?

Uncertain what you mean by "tune". I am checking for the EIT packet. I did not spot anything to configure for the packet.

	dmx := astits.NewDemuxer(ctx, f)
	for {
		// Get the next data
		d, err := dmx.NextData()
		if err == astits.ErrNoMorePackets {
			log.Fatal(err)
		}
		if err != nil {
			fmt.Printf("Error: %v\n", err)
			continue
		}

		if d.EIT != nil {
			fmt.Printf("found EIT\n")
			for _, evt := range d.EIT.Events {
				fmt.Printf("Event detected: %v\n", evt)
			}
		}
	}

How did you capture the mpegts stream from the tuner?

Via a curl against the channel endpoint (here).

$ curl http://192.168.1.114:5004/auto/ch177000000 > capture.ts

If I run dvbtee against it I see parts of the schedule in that file:

$ dvbtee -F ~/Documents/Source/hdhr/experiment/capture.ts 
<snip>
dump_epg_event: id:7 - 7.5: Quest	2022-11-13 22:59-23:59 Dual Survival
dump_epg_event: id:8 - 7.6: Circle	2022-11-13 19:59-21:59 The Gunfighter
dump_epg_event: id:8 - 7.6: Circle	2022-11-13 21:59-22:29 Paid Program
dump_epg_event: id:8 - 7.6: Circle	2022-11-13 22:29-00:29 The Gunfighter
<snip>

When using the go-astits I don't see that. I do read ~6500 packets, however, so I do know it's finding some set of packets.
If you're interested, I can upload the capture (~30MB) file or a smaller version I was using.

Guessing this doesn't help, but here's a hexdump with some of the program guide:

00f77b40  68 f0 74 dc 47 4f a3 18  00 cb f0 c3 00 08 cf 00  |h.t.GO..........|
00f77b50  00 00 03 c0 d2 50 9c 63  a0 e0 1c 20 16 01 65 6e  |.....P.c... ..en|
00f77b60  67 01 00 00 0e 54 68 65  20 47 75 6e 66 69 67 68  |g....The Gunfigh|
00f77b70  74 65 72 f0 1a 81 0a e8  3d 05 ff 1f 01 bf 65 6e  |ter.....=.....en|
00f77b80  67 87 0c c1 01 00 08 01  65 6e 67 01 00 00 00 c0  |g.......eng.....|
00f77b90  d3 50 9c 7f c0 e0 07 08  14 01 65 6e 67 01 00 00  |.P........eng...|
00f77ba0  0c 50 61 69 64 20 50 72  6f 67 72 61 6d f0 20 81  |.Paid Program. .|
00f77bb0  0a e8 3d 05 ff 1f 01 bf  65 6e 67 87 12 c1 01 01  |..=.....eng.....|
00f77bc0  00 f2 0c 01 65 6e 67 01  00 00 04 54 56 2d 47 c0  |....eng....TV-G.|
00f77bd0  d4 50 9c 86 c8 e0 1c 20  16 01 65 6e 67 01 00 00  |.P..... ..eng...|
00f77be0  0e 54 68 65 20 47 75 6e  66 69 67 68 74 65 72 f0  |.The Gunfighter.|
00f77bf0  1a 81 0a e8 3d 05 ff 1f  01 bf 65 6e 67 87 0c c1  |....=.....eng...|
00f77c00  47 00 31 13 dc ad b5 d1  1b 36 56 ba d9 39 a2 6a  |G.1......6V..9.j|
00f77c10  01 47 2e 45 52 c6 cc 14  7c 7b 76 d6 79 35 aa 65  |.G.ER...|{v.y5.e|
00f77c20  68 35 b5 f2 68 92 80 a1  0c 96 9f 35 b2 c2 ca 42  |h5..h......5...B|

If you're interested, I can upload the capture (~30MB) file or a smaller version I was using.

Could you share the smaller version with the result you get from dvbtee?

Certainly! (Sorry, Github requires a .ts to be zipped, so... lol)
a000.zip

First, I tweaked astits-probe to not return on error but to continue since these are streams that aren't clean at the beginning or end.

$ ../go-astits/cmd/astits-probe/main -d eit -i ./a000.ts 
2022/11/18 13:28:30 Fetching data...
Programs are:
2022/11/18 13:28:30 * [5] - Map ID: 80 - unlisted descriptor tag 0x5
  * [81] - Type: unlisted stream type 2 - unlisted descriptor tag 0x2 - unlisted descriptor tag 0x6 - [Maximum bitrate] maximum bitrate: 2000000
  * [84] - Type: unlisted stream type 129 - [ISO639 language and audio type] language: eng | audio type: 0 - unlisted descriptor tag 0x5 - unlisted descriptor tag 0x81 - [Maximum bitrate] maximum bitrate: 55550
  * [85] - Type: unlisted stream type 129 - [ISO639 language and audio type] language: spa | audio type: 0 - unlisted descriptor tag 0x5 - unlisted descriptor tag 0x81 - [Maximum bitrate] maximum bitrate: 22900
2022/11/18 13:28:30 * [6] - Map ID: 96 - unlisted descriptor tag 0x5
  * [97] - Type: unlisted stream type 2 - unlisted descriptor tag 0x2 - unlisted descriptor tag 0x6 - [Maximum bitrate] maximum bitrate: 750000
  * [100] - Type: unlisted stream type 129 - [ISO639 language and audio type] language: eng | audio type: 0 - unlisted descriptor tag 0x5 - unlisted descriptor tag 0x81 - [Maximum bitrate] maximum bitrate: 55550
  * [101] - Type: unlisted stream type 129 - [ISO639 language and audio type] language: spa | audio type: 0 - unlisted descriptor tag 0x5 - unlisted descriptor tag 0x81 - [Maximum bitrate] maximum bitrate: 22900
<snip>

... and dvbtee of that file ...

$ vbtee -E -F ./a000.ts
# dvbtee v0.6.8 - http://github.com/mkrufky/libdvbtee

_open_file: using ./a000.ts
	TEIstore PAT: v8, ts_id: 3247
           0 | 10
           3 | 30
           4 | 40
           5 | 50
           6 | 60
           7 | 70
           8 | 80
store MGT: v27
  table type |   pid  | ver | bytes
    0x0000   | 0x1ffb |   1 | 325
    0x0100   | 0x0fa0 |  11 | 1613
    0x0101   | 0x0fa1 |  11 | 1991
    0x0102   | 0x0fa2 |  13 | 2268
    0x0103   | 0x0fa3 |   7 | 2816
    0x0200   | 0x1388 |  26 | 3015
    0x0201   | 0x1389 |  26 | 3811
    0x0202   | 0x138a |  26 | 4367
    0x0203   | 0x138b |  26 | 5359
store PMT: v0, service_id 3, pcr_pid 49
  es_pid | type
      31 | 0x02 (Video MPEG-2) | 
      34 | 0x81 (Audio AC3 (ATSC)) | eng
      35 | 0x81 (Audio AC3 (ATSC)) | spa
store PMT: v0, service_id 5, pcr_pid 81
  es_pid | type
      51 | 0x02 (Video MPEG-2) | 
      54 | 0x81 (Audio AC3 (ATSC)) | eng
      55 | 0x81 (Audio AC3 (ATSC)) | spa
store PMT: v0, service_id 4, pcr_pid 65
  es_pid | type
      41 | 0x02 (Video MPEG-2) | 
      44 | 0x81 (Audio AC3 (ATSC)) | eng
store PMT: v0, service_id 6, pcr_pid 97
  es_pid | type
      61 | 0x02 (Video MPEG-2) | 
      64 | 0x81 (Audio AC3 (ATSC)) | eng
      65 | 0x81 (Audio AC3 (ATSC)) | spa
store PMT: v0, service_id 7, pcr_pid 113
  es_pid | type
      71 | 0x02 (Video MPEG-2) | 
      74 | 0x81 (Audio AC3 (ATSC)) | eng
store PMT: v0, service_id 8, pcr_pid 129
  es_pid | type
      81 | 0x02 (Video MPEG-2) | 
      84 | 0x81 (Audio AC3 (ATSC)) | eng
store VCT: v1, ts_id 3247, b_cable_vct 0
  channel | service_id | source_id | service_name
      7.1 |          3 |         3 | CBS | 
      7.2 |          4 |         4 | MeTv+ | 
      7.3 |          5 |         5 | FOX | 
      7.4 |          6 |         6 | CW | 
      7.5 |          7 |         7 | Quest | 
      7.6 |          8 |         8 | Circle | 
store EIT-255: v11, source_id 3
  10:59 - 11:59 : The NFL Today
  11:59 - 15:59 : NFL Football:  Jacksonville @ Kansas City
store EIT-255: v11, source_id 8
  11:29 - 11:59 : Circle Country Countdown
  11:59 - 12:29 : Betty White's Off Their Rockers
  12:29 - 12:59 : Betty White's Off Their Rockers
  12:59 - 15:59 : Cool Hand Luke
store EIT-255: v11, source_id 4
  10:59 - 15:59 : The Summer of Me Sunday Block Party
store EIT-255: v11, source_id 6
  11:29 - 11:59 : The Big Bang Theory
  11:59 - 12:29 : The Big Bang Theory
  12:29 - 12:59 : The Big Bang Theory
  12:59 - 14:59 : 10,000 Saints
<snip>

Thanks for the .ts 👍

Basically go-astits implements DBV tables only whereas your file contains ATSC tables. Implementing ATSC tables is a tall task and I don't know when that'll be available.

For references here are the latest specs I've found:

As usual, I'm welcoming PRs if somebody feels like implementing it 👍

Ok. Thanks! There is so much detail in these standards it's hard to understand the details. Feel free to close the ticket... although with the name change, I suspect the intent is to leave it open.