从PTS生成PCR [英] Generate PCR from PTS

查看:260
本文介绍了从PTS生成PCR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试如下从PTS创建PCR.

I am trying to create PCR from PTS as follows.

        S64 nPcr = nPts * 9 / 100;  
        pTsBuf[4] = 7 + nStuffyingBytes;  
        pTsBuf[5] = 0x10;   /* flags */  
        pTsBuf[6] = ( nPcr >> 25 )&0xff;  
        pTsBuf[7] = ( nPcr >> 17 )&0xff;  
        pTsBuf[8] = ( nPcr >> 9  )&0xff;  
        pTsBuf[9] = ( nPcr >> 1  )&0xff;  
        pTsBuf[10]= ( nPcr << 7  )&0x80;  
        pTsBuf[11]= 0; 

但是问题是VLC仅播放第一帧,而不播放任何其他帧. 并且我收到警告早期图片已跳过".

But the problem is VLC is playing only first frame and not playing any other frames. and I am getting the warning "early picture skipped".

谁能帮助我从PTS转换为PCR.

Could any one help me in converting from PTS to PCR..

推荐答案

首先,PCR具有33 + 9位,PTS为33位. 33位部分(称为PCR_base)与PTS一样以90kHz运行.其余9位称为PCR_ext,运行频率为27MHz.

First, the PCR has 33+9 bits, the PTS 33 bits. The 33 bit-portion (called PCR_base) runs at 90kHz, as does the PTS. The remaining 9 bits are called PCR_ext and run at 27MHz.

因此,这是计算PCR的方式:

Thus, this is how you could calculate the PCR:

S64 nPcr = (S64)nPts << 9;

请注意,在多路复用流的PTS与PCR之间应该有一个时间偏移,通常在几百毫秒的范围内,具体取决于流.

Note that there should be a time-offset between the PTSs of the multiplexed streams and the PCR, it's usually in the range of a few hundred ms, depending on the stream.

各个解码器需要一些时间来对数据进行解码,并使其在各个PTS给出的时间准备好呈现,这就是PTS始终位于PCR之前的原因. ISO-13818和一些DVB规范提供了有关缓冲和(解复用)的详细信息.

The respective decoder needs some time to decode the data and get it ready for presentation at the time given by the respective PTS, that's why the PTSs are always "ahead" of the PCR. ISO-13818 and some DVB specs give specifics about buffering and (de)multiplexing.

关于您的移位,我不确定,这是我的代码段.注释可能有助于将位移到正确的位置,R表示保留.

About your bitshifting I'm not sure, this is a code snippet of mine. The comment may help in shifting the bits to the right place, R stands for reserved.

data[4] = 7;
data[5] = 1 << 4;   // PCR_flag

// pcr has 33+9=42 bits

//        4           3          2          1          0
// 76543210 98765432 10987654 32109876 54321098 76543210
// xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx xRRRRRRx xxxxxxxx
// 10987654 32109876 54321098 76543210 9      8 76543210
//  4          3          2          1                 0
// b6       b7       b8       b9       b10      b11

data[ 6] = (pcr >> 34) & 0xff;
data[ 7] = (pcr >> 26) & 0xff;
data[ 8] = (pcr >> 18) & 0xff;
data[ 9] = (pcr >> 10) & 0xff;
data[10] = 0x7e | ((pcr & (1 << 9)) >> 2) | ((pcr & (1 << 8)) >> 8);
data[11] = pcr & 0xff;

这篇关于从PTS生成PCR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆