本文介绍了如何从Hex中的PCR生成时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用tsduck检查传输流时,我可以看到某些数据包在Hex中包含PCR值.我不确定如何将其转换为时间戳.

When inspecting a transport stream using tsduck, I can see that some packets contains a PCR value in Hex. I am not sure how to convert these into timestamps.

例如,在以下数据包中,PCR值为0x000002014CE

For example, in the packet below the PCR value is 0x000002014CE

* Packet 179
  ---- TS Header ----
  PID: 481 (0x01E1), header size: 25, sync: 0x47
  Error: 0, unit start: 1, priority: 0
  Scrambling: 0, continuity counter: 4
  Adaptation field: yes (21 bytes), payload: yes (163 bytes)
  Discontinuity: 0, random access: 0, ES priority: 0
  PCR: 0x000002014CE
  ---- PES Header ----
  Stream id: 0xE0 (Video 0)
  PES packet length: 0 (unbounded)
  ---- Full TS Packet Content ----
  47 41 E1 34 14 12 00 00 0D B0 7E 4E 0C 02 0A 22 8E 00 00 D1 2D 03 64 00
  29 00 00 01 E0 00 00 84 C0 0A 31 00 07 44 B7 11 00 05 D4 37 00 00 00 01
  09 30 00 00 01 06 01 03 03 84 19 80 00 00 01 41 9A 84 93 D1 13 7F F0 28
  2C 26 B5 35 90 10 B7 32 8C FF 00 D3 47 BE 4C 9A 83 AE CD B8 9C 09 5A 60
  07 BE C4 F2 2C 5D D3 24 6C 7F A0 E1 C4 7B BC FA 37 CA C5 C0 B0 C4 2C 91
  96 09 07 22 C4 A8 55 FF C2 BF 0E 7E 10 74 6D 84 F2 08 9D D0 29 52 7F 2B
  F6 3E C8 23 1F BC 4E 80 C3 AE FD AC F4 96 08 E5 13 C8 A7 41 20 B4 F6 F8
  E1 14 4A 03 4C 8E 98 00 04 73 2D AE 83 31 0B C8 61 03 3A A1

我尝试查看的是其中包含PCR值的数据包的前几个实例,然后将其转换为十进制,然后除以90,000,这是PCR时钟的时钟速率(即时基).

What I tried is looking at the first few instances of packets that had the PCR values in them, then converting them to decimal and subsequently dividing by 90,000 which is the clock rate of the PCR clock (i.e the timebase).

但是看最后一栏,它看起来不正确.间隔似乎太高.我以为PCR必须至少每100毫秒左右插入一次PCR标记,但这似乎太少了....

But looking at the last column, it doesn't look right. It would seem that the intervals are too high. I thought that the PCR must insert PCR stamps at least every 100ms or so, but this seems to be too infrequent....

推荐答案

您没有使用正确的时基.如果查看发布的示例,tsduck将PCR显示为0x000002014CE,但是该十六进制值根本不会出现在该数据包中.原因是PCR不仅仅是一个时间戳,它是2个时间戳.十六进制中的PCR实际上是00 00 0D B0 7E 4E,那么我们如何从0xDB07E4E0x2014CE?我们通过将0xDB07E4E右移15位来提取90 kHz分量,然后通过屏蔽掉前39位来提取27MHz分量.然后将90kHz分量乘以300,以转换为27MHz (300=27000000/90000)并将两个值相加:

You are not using the correct time base. If you look at the example you posted, tsduck shows the PCR as 0x000002014CE But that hex value does not show up in that packet at all. The reason is the PCR is more than just a time stamp, Its 2 timestamps. The PCR in the hex is actually 00 00 0D B0 7E 4E So how do we get from 0xDB07E4E to 0x2014CE? We extract the 90 kHz component by shifting 0xDB07E4E right by 15 bits, Then extract the 27MHz component by masking off the top 39 bits. Then multiply the 90kHz component by 300 to convert to 27MHz (300=27000000/90000) and add the two values together:

300*(0xDB07E4E>>15) + (0xDB07E4E&0x1ffff) = 0x2014CE

我们现在有了27MHz的时间戳.要将其转换为秒,请除以27000000

We now have the 27MHz timestamp. To convert that to seconds, divide by 27000000

0x2014CE/27000000=0.0779

因此:

0x58e54 = 0.0135
0x78707 = 0.0183

TLDR:时基是27000000,而不是90000

TLDR: time base is 27000000, not 90000

这篇关于如何从Hex中的PCR生成时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-05 07:44