Could not workaround the problem
kivancguckiran opened this issue · 16 comments
Hello, thanks for the project.
'use strict';
const fs = require('fs');
const dvbtee = require('dvbtee');
const parser = new dvbtee.Parser();
parser.on('data', (data) => {
console.log('table id: ' + data.tableId,
'\ntable name: ' + data.tableName,
'\ntable data:\n', JSON.stringify(data, null, 2));
});
fs.createReadStream('FILE.ts').pipe(parser);
Nothing happens. I could not manage to fix it. Any idea?
does examples/pipefile.js
work for you?
Same. No output.
Then it's most likely not a transport stream. Can you share your FILE.ts
with me somehow?
Sure thing. Hang on.
hmm... it looks like valid TS but something is weird... I don't have a lot of time right now, but I'll take a closer look later on.
dvbtee -d -j -F FILE.ts
# dvbtee v0.6.0 - http://github.com/mkrufky/libdvbtee
1507637984 LOG::libdvbtee_set_debug_level: (0xff)
1507637984 feed::set_filename: (/home/mk/node-dvbtee/FILE.ts)
1507637984 feed::_open_file: ()
_open_file: using /home/mk/node-dvbtee/FILE.ts
1507637984 feed::file_feed_thread: (fd=4)
1507637984 parse::take_pat: (pre): v0, ts_id: 0
1507637984 parse::set_ts_id: (0000|0)
1507637984 decode::decode: ()
1507637984 parse::set_detach: attaching table 42|0000...
1507637984 parse::take_sdt_actual: (pre): v7 | ts_id 0 | network_id 1
1507637984 parse::set_ts_id: (0000|0)
1507637984 feed::close_file: ()
1507637984 feed::stop: ()
1507637984 listen::stop: ()
1507637984 feed::stop: waiting...
1507637984 feed::stop: done
1507637984 feed::close_file: ()
TSID#0000: []
1507637984 feed::stop: ()
1507637984 listen::stop: ()
1507637984 feed::stop: waiting...
1507637984 feed::stop: done
1507637984 feed::close_file: ()
1507637984 parse::cleanup: ()
1507637984 parse::detach_demux: ()
1507637984 decode::~decode: (ffff|65535)
1507637984 feed::~feed: (/home/mk/node-dvbtee/FILE.ts)
1507637984 feed::close_file: ()
1507637984 listen::~socket_listen: ()
1507637984 listen::close_socket: ()
1507637984 parse::~parse: ()
1507637984 parse::cleanup: ()
1507637984 parse::detach_demux: ()
398937 packets read in total
1507637984 out::~output: ()
1507637984 out::stop: ()
1507637984 out::~output: (intermediate) 3000 packets in, 0 packets out, 0 packets remain in rbuf
1507637984 listen::~socket_listen: ()
1507637984 listen::close_socket: ()
1507637984 rbuf::~rbuf: ()
1507637984 rbuf::dealloc: ()
Seems malformed, but I'm not yet sure exactly why. Where did this come from?
This is the output of our company's encoder which I'm trying to write an analyzer for it. This is the file output, so there might be some PCR accuracy errors because of the re-alignment of the audio packets according to PTS values. But I don't expect any other errors.
No output in our UDP multicast too(dumped via VLC). I can upload that too if you want to take a look at.
@kivancguckiran libdvbtee aborts the table storage (and event delivery) because TS ID is zero and libdvbtee think's it's calling the provider's bluff.
It's not a bug -- it's a "feature" that should probably be removed. I'll get around to that in a few days most likely. In the real world of broadcast, we never see a zero TS id or all zeroed PSIP values... at least not often. But libdvbtee can handle it so I'll fix it.
In the meantime, change your encoder to fill in some of your PSIP with NON-ZERO values and then libdvbtee will pick it up.
I hacked in a little experiment to prove my theory and this is what I see now:
./dvbtee/dvbtee -j -F ~/node-dvbtee/FILE.ts
# dvbtee v0.6.1 - http://github.com/mkrufky/libdvbtee
_open_file: using /home/mk/node-dvbtee/FILE.ts
store PAT: v0, ts_id: 0
1 | 42
store PMT: v3, service_id 1, pcr_pid 68
es_pid | type
44 | 0x1b (Video H.264) |
45 | 0x0f (Audio AAC MPEG-2 (ADTS)) | tur
store SDT: v07, ts_id 00000, network_id 00001
svcId | EIT avail | provider | service name
00001 | | DogalZeka - WORLD
TSID#0000: [{"programs":[{"number":1,"pid":66}],"tableId":0,"tableName":"PAT","tsId":0,"version":0},{"pcrPid":68,"program":1,"streams":[{"pid":68,"streamType":27,"streamTypeString":"Video H.264"},{"descriptors":[{"ISO639Lang":[{"audioType":0,"language":"tur"}],"descriptorTag":10}],"pid":69,"streamType":15,"streamTypeString":"Audio AAC MPEG-2 (ADTS)"}],"tableId":2,"tableName":"PMT","version":3},{}]
NET_ID#0001: [{}]
NET_SVC_ID#0000: [{"networkId":1,"services":[{"descriptors":[{"descriptorTag":72,"providerName":"DogalZeka","serviceName":"WORLD"}],"f_eit_present":false,"f_eit_sched":false,"f_free_ca":false,"runningStatus":4,"serviceId":1}],"tableId":66,"tableName":"SDT","tsId":0,"version":7}]
398937 packets read in total
^^ That was generated from the c++ command line tool. Using node-dvbtee
, the command node examples/pipefile.js ~/node-dvbtee/FILE.ts
generates the following:
{ programs: [ { number: 1, pid: 66 } ],
tableId: 0,
tableName: 'PAT',
tsId: 0,
version: 0 }
,
{ pcrPid: 68,
program: 1,
streams:
[ { pid: 68, streamType: 27, streamTypeString: 'Video H.264' },
{ descriptors:
[ { ISO639Lang: [ { audioType: 0, language: 'tur' } ],
descriptorTag: 10 } ],
pid: 69,
streamType: 15,
streamTypeString: 'Audio AAC MPEG-2 (ADTS)' } ],
tableId: 2,
tableName: 'PMT',
version: 3 }
,
{ networkId: 1,
services:
[ { descriptors:
[ { descriptorTag: 72,
providerName: 'DogalZeka',
serviceName: 'WORLD' } ],
f_eit_present: false,
f_eit_sched: false,
f_free_ca: false,
runningStatus: 4,
serviceId: 1 } ],
tableId: 66,
tableName: 'SDT',
tsId: 0,
version: 7 }
I think your encoder is doing the wrong thing by setting TS id to zero. It might be legal but it's certainly uncommon. I have to think about this. I'm not sure if I want to fix this for all cases -- I might just make it an "option", disabled by default, to force-parse a zero TS
I didn't understand what you mean by TS ID. You mean PID?
There are I think 6 types of TS package inside that file.
- PAT, Program Association Table, PID=0
- PMT, Program Map Table, PID variable
- SDT, Service Description Table, PID=17
- Video Stream, PID=68, PCR PID is also this.
- Audio Stream, PID=69
- Stuffing packets, PID=8191, used for bitrate.
Which one is it? Where does it store inside a 188 byte TS Packet? Maybe I am not aware something called ts id exists.
I think it's the transport_stream_id inside the SDT. Correct? I didn't think that effects anything, I will try some other value. Thanks.
TS ID is the transport stream ID in all tables. It must be set in all applicable tables, not just SDT.
Yes, that's correct, I double checked.
To test, I used FFMPEG to demux and mux transport stream I've provided. FFMPEG assigned transport stream id of the tables to "1". I'm going to change our encoder to produce the same since the common practice is this way. Maybe MPTS files use multiple transport stream ids. I'm going to test further.
Thanks for your time.
Looking at this with fresh eyes this morning, I see an easy fix for this that probably has no side effects. Will be pushing that into master soon...
@kivancguckiran if you rebuild node-dvbtee
from the git repo (make sure its a fresh clone -- or delete the libdvbtee/
folder inside the one you may already have) then it should be able to happily parse your streams
Will do, @mkrufky thanks.