-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TS encapsulation of Teletext PES for tsduck #35
Comments
Here are the source files |
Great work,
Indentation is out. any chance to add this snippet in a test folder under
TS duck?
Rob
…On Sat, 25 Feb 2023 at 07:05, omikron88 ***@***.***> wrote:
I made some tests with including teletext packets to tsduck live streams
This worked for me: (written in Python)
`
def send_ts():
global ts, pid, pes,
ts_payload, ts_index, ts_cc,
TS_PACKET_SIZE, TS_HEADER_SIZE
temp = TS_PACKET_SIZE - TS_HEADER_SIZE
if ts_payload >= temp:
ts[3] = ts_cc | 0x10 # continuity counter, no scrambling, only payload
ts_cc = (ts_cc + 1) % 0x10 # inc.continuity counter
ts[TS_HEADER_SIZE:] = pes[ts_index:ts_index + temp]
sys.stdout.buffer.write(ts)
# out.write(ts)
ts_payload -= (TS_PACKET_SIZE - TS_HEADER_SIZE)
ts_index += (TS_PACKET_SIZE - TS_HEADER_SIZE)
ts[1] = (pid >> 8) & 0x1F # pid not payload unit start
ts[2] = (pid & 0xFF)
if ts_payload != 0:
send_ts()
else:
ts[3] = ts_cc | 0x30 # continuity counter, no scrambling, adaptation field
and payload
ts_cc = (ts_cc + 1) % 0x10 # inc.continuity counter
ts[TS_PACKET_SIZE - ts_payload:] = pes[ts_index:ts_index + ts_payload]
ptr = TS_PACKET_SIZE - ts_payload # point to the first payload byte
ts[4] = ptr - TS_HEADER_SIZE -1
ts[5] = 0x00 # no options
for temp in range(6, ptr):
ts[temp] = 0xFF
sys.stdout.buffer.write(ts)
# out.write(ts)
ts_payload = 0
def init_ts():
global pid, ts_payload, ts_cc,
TS_PACKET_SIZE
ts = bytearray(b'\xff') * TS_PACKET_SIZE
ts_payload = 0
ts_cc = 0
return ts
def add_ts(size):
global pid, ts_payload, ts_index
ts_payload = size
ts_index = 0
ts[0] = 0x47 # sync
ts[1] = (pid >> 8) & 0x1F # pid
ts[2] = (pid & 0xFF)
ts[1] |= 0x40 # payload unit start indicator
send_ts()
def init_pes(pes_size):
global packet_index, EBU_UNIT_SIZE
pes = bytearray(b'\xff') * pes_size
pes[0] = 0x00
pes[1] = 0x00
pes[2] = 0x01 # prefix
pes[3] = 0xBD # data
temp = pes_size - 6
pes[4] = (temp >> 16) & 0xFF
pes[5] = (temp & 0xFF)
pes[6] = 0x85
pes[7] = 0x80 # flags
pes[8] = 0x24 # header size
# 31 0xFF stuffing here
pes[45] = 0x10 # ebu teletext
packet_index = EBU_UNIT_SIZE
return pes
def stamp_pts(stamp):
global pes
pes[9] = ((stamp >> 29) & 0x0F) | 0x21
pes[10] = (stamp >> 22) & 0xFF
pes[11] = ((stamp >> 14) & 0xFF) | 0x01
pes[12] = (stamp >> 7) & 0xFF
pes[13] = ((stamp << 1) & 0xFF) | 0x01
def add_pes(buffer):
global pes, packet_index, pes_size,
pts_stamp, pts_increment,
EBU_UNIT_SIZE
pes[packet_index:] = buffer[0:]
packet_index += EBU_UNIT_SIZE
if packet_index == pes_size:
stamp_pts(pts_stamp)
add_ts(pes_size)
pts_stamp += pts_increment
packet_index = EBU_UNIT_SIZE
`
The PES packets need to include PTS timestamp. Because tsduck merge plugin
controls the insert rate. pts_increment is 1800 for 50Hz time advance, or
3600 for 25Hz time advance. It is in 90kHz units.
Next goes the encapsulation to 188 byte TS packets. pid is the required
PID from 0x0100 to 0x1FFE.
It is possible to inject the resulting packets into live tsduck steam with
acceptable time error:
-P merge "gener .... "
Of course, there is also need to add the reqired signalisation to PSI
tables:
ttx.xml:
`
` edit your language, start page, PID and VBI lines used. And patch the
PMT table by -P pmt --patch-xml ttx.xml
Have a nice day
—
Reply to this email directly, view it on GitHub
<#35>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM4O2S4K3ZEDTUPF5RZSELTWZEICNANCNFSM6AAAAAAVHJMTI4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
I'm just beginning to play with getting vbit2 to send to TSduck. |
I found your bash file.. I got Teletext working with VLC however the PCR's is way high.
My script below, anything which l could improve? tsp -v -b 480000 ^ |
The above method kind of worked however, I have heaps of PCR discontinuity errors. Video stopping. lost frames etc. TSduck has the capacity to manufacture a TS from the ground up and just add all what is needed to make the stream compliant. Taken from the TSduck documentation with the TXT stuff added from above. BITRATE=400000 What do you think? |
Hello @omikron88. Thanks for your contribution. I'm converting your python code to Go code to expand further in generation of both a 4-6 page carousel to cycle a static and a few dynamically generated pages to further provide a live teletext service. I'd like to understand generating the t42 stream to do such? I'll need to update the date and time in the header and developed pages to show system stats such as cpu and gpu, ram usage etc. I like the idea of a teletext fish tank however working out how I can replicate such in code require some thought. https://youtu.be/zFkBHuchOnk?si=utewe3efCCaLMgtL SonnyWalkman |
It doesn't sound too difficult to generate the fish tank. You could adapt code from vbit2 as that already generates t42 and has everything needed to generate packets and sequence them correctly. |
I’m coding in Go there looking at a small device to produce a index with a
few dynamic pages like weather, club news and a few engineering pages like
test charts and of course fish tank.
I have an idea using asciiaquarium however it written in Perl and leverages
off a few packages to work.
The concept is all there however, structuring fish and other objects in
teletext block art is a skill. At 40x25 lines
Regards
Rob aka SonnyWalkman
Sent from Gmail Mobile iPhone 14
…On Mon, 30 Oct 2023 at 8:11 pm, Peter Kwan ***@***.***> wrote:
It doesn't sound too difficult to generate the fish tank. You could adapt
code from vbit2 as that already generates t42 and has everything needed to
generate packets and sequence them correctly.
—
Reply to this email directly, view it on GitHub
<#35 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM4O2S2QWOCYKXON5I6FQN3YB5VNXAVCNFSM6AAAAAAVHJMTI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBUG43TAOJUGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Following on from a discussion on the facebook teletext group, I've hacked together some code to generate a PTS and encapsulate the PES output in a transport stream in a new branch. It builds a PCR and PTS from the internal field count which tsduck can then resynchronize to another stream. |
Wow that was quick. I’ll get if a shot and send you feedback.
ZXGuesser, I appreciate your time and motivation in adding PTS time
stamping and TS encapsulation.
…On Sun, 12 Nov 2023 at 7:47 am, ZXGuesser ***@***.***> wrote:
Following on from a discussion on the facebook teletext group, I've hacked
together some code to generate a PTS and encapsulate the PES output in a
transport stream in a new branch: 1c97af2
<1c97af2>.
It builds a PCR and PTS from the internal field count which tsduck can then
resynchronize to another stream.
I've been able to successfully merge this into a live transport stream
with tsduck.
—
Reply to this email directly, view it on GitHub
<#35 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AM4O2S4JHIJ4TWFOI3JX5PDYD7P7JAVCNFSM6AAAAAAVHJMTI6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBWHEYTGNRQGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I got thoroughly nerdsniped on this one, but the chances are I wasn't going to get anything else done today anyway 😂 |
The latest code adds a |
Made some more small tweaks to correct the TS continuity counters, so tsanalyze doesn't report a zillion continuity errors now. I think it's ready to merge but would appreciate more testing, particularly against real DVB hardware, before I release. |
I think Teletext PID without PTS may be the preferred way here. Or it needs a PCR reference input (e.g. video stream). |
Certainly that was my feeling, that it seems like every teletext decoder is happy ignoring the lack of a PTS, but @SonnyWalkman wanted it for some reason! 😆 |
Added another format |
Hello @ZXGuesser and @premultiply,
The reasoning behind the PTS and PCR functionality was to acknowledge the DVB standard in providing a PTS to cater for device requiring a PTS even though the device could disregard the PTS altogether. Is there a chance to add my fix to stop killing the VBIT process if the remote connection receives zero (TCP disconnect) and negative value on error. Should be handled correctly. @peterkvt80 may not be able/available to look at the issues with the remote commands returning errors. 'P', 'L' and 'R' commands are broken. If we could resolve these few issues, then there be a few more happy users. |
I have not found any device with a requirement for PTS on TXT PID yet. They all ignore it completly even if it exists. |
Just enforcing the specification. Taken for en_300472v010401 2017 Annex A (informative): |
Yep, from todays all-IP practical playout system design it is not easy to mux a teletext PID with a valid PTS as it was in the analog or digital SD days. IF you (still) have an encoder supporting teletext at all, most of the times this requires a teletext insertion into SDI using SMPTE2031 or OP-47 insertion and transport at the input of each encoding device for each tv service. But most of the audio+video encoding systems do not have any support for teletext so the only way to go is to add it afterwards by muxing the teletext PID (without PTS) into the the "main" TS with video and audio. |
Released as v2.6.0 |
I made some tests with including teletext packets to tsduck live streams
This worked for me: (written in Python)
The PES packets need to include PTS timestamp. Because tsduck merge plugin controls the insert rate. pts_increment is 1800 for 50Hz time advance, or 3600 for 25Hz time advance. It is in 90kHz units.
Next goes the encapsulation to 188 byte TS packets. pid is the required PID from 0x0100 to 0x1FFE.
It is possible to inject the resulting packets into live tsduck steam with acceptable time error:
-P merge "gener .... "
Of course, there is also need to add the reqired signalisation to PSI tables:
ttx.xml.
edit your language, start page, PID and VBI lines used. And patch the PMT table by
-P pmt --patch-xml ttx.xml
Source files are in next message
Have a nice day
source.zip
The text was updated successfully, but these errors were encountered: