使用神龙卡开发硬解压如何获取媒体时间及媒体类型,路过的也帮忙提前。。。。。。。。 ,回答正确后再加分,分数自己开........ (100分)

  • 主题发起人 主题发起人 yym
  • 开始时间 开始时间
Y

yym

Unregistered / Unconfirmed
GUEST, unregistred user!
一、获取时间
FMPSet(MPEGStream, FMPI_STM_TIME_FMT, FMPF_HMSF);
FMPGet(MPEGStream, FMPI_STM_FILESIZE);
//将FMPF_HMSF改变为下面的值可获取不同结果,但如何转换出时间呢?如XX时XX分XX秒
const FMPF_BYTES = $0001;
const FMPF_SAMPLES = $0002;
const FMPF_MSEC = $0003;
const FMPF_HMSF = $0004;
const FMPF_HMSC = $0005;
const FMPF_FRAMES = FMPF_SAMPLES;
const FMPF_TIME = FMPF_HMSC;
const FMPF_SMPTE = FMPF_HMSF;
二、媒体类型
FMPGet(MPEGStream, FMPI_VID_TYPE);//得到的结果好象不正确,有些MPEG2的也识别成一,或是否有其他方法?
FMPI_VID_TYPE type of the video streamr FMPF_VID_MPEG MPEG 1 video streamor FMPF_VID_MPEG2 MPEG 2 video stream
三、是否有人做过TV和VGA同步显示的?

先奉上一百分,回答后再加。。。
 
强 烈 关 注
 
哈哈,我回‘强烈关注 ’这样的字样系统提示我不要灌水,
那就改成'强 烈 关 注 '
 
呵呵,楼主这个问题问了好几个帖子吧,
最好是从MPEG文件中分析,具体的文件类型判断我写过,不过使用VC写的,如果需要,可以QQ联系。
媒体时间最好用PTS和DTS来判断,PTS DTS(时间戳)也在MPEG文件中
提示楼主可以参考以下协议:
ISO/IEC 11172 (MPEG-1)
ISO/IEC 13813 (MPEG-2)
 
搜索pack_header=0x000001BA之后的一位,mpeg1 为0x00 mpeg2为0x01
 
我的另一问题
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2380377
要了解格式看来要对协议比较了解,有现成的程序段就好。还以为用一两句就可摆平。
 
发代码给你
DWORD CheckForStartCode(HANDLE hFile)
{
BYTE temp_byte;
DWORD temp = 0;
DWORD start_code = 0xFFFFFFFF;

char *ptr = _T("");

DWORD dwBytesRead;

int iFlag=0;
unsigned long len=0;

LPVOID lp;
BOOL bSuccess;

lp = GlobalAlloc( GMEM_ZEROINIT,MAX_BUF_SIZE);
do
{
bSuccess = ReadFile(hFile,lp,MAX_BUF_SIZE, &dwBytesRead,NULL);
if (dwBytesRead &&
bSuccess)
{
ptr=(char *)lp;
temp = 0;
while (temp <= dwBytesRead)
{
if(!( start_code== 0x000001BA))
{
temp_byte = *(BYTE *)ptr;
start_code = (start_code <<8)|temp_byte;
ptr++;
temp++;

len++;
iFlag = 0;
}
else

{
ptr++;
temp_byte = *(BYTE *)ptr;
iFAudioType=temp_byte+1;

iFlag = 1;
break;
}
}

if (iFlag) break;

}
else

{
break;
}

} while (1) ;

GlobalFree(lp);
return iFlag;
}
0为mpeg1
1为mpeg2
 
谢谢aijun,刚试过一个mpeg2文件没有0x000001ba的字符,但它确实是一个mpeg2文件,另一个有但后面是44
 
ISO 11172-2.4.3.2章节有介绍
ISO 11172 Pack Layer
pack_start_code 后4个比特固定为'0010'

ISO/IEC 13818-2 program stream
pack_start_code 后两个比特固定为'01'

ISO 11172和ISO/IEC 13818-2均为
pack_start_code=0x000001BA
pack_end_code=0x000001B9

所以只需知道pack_start_code 后两个比特就知道媒体压缩类型

 
MPEG-2也是分节目流()和传输流的,(Program Stream和Transport Stream),没有0x000001ba不一定就不是MPEG文件,可能被认为截掉了,你可以试试,截掉一半的MPEG文件神龙卡照样可以播放。
我觉得你应该从图组头分辨MPEG-1和MPEG-2文件[:D]
 
神龙卡sdk的一段说明说得很明白:
播放时候FMP driver 将搜索以下标志确定媒体类型
MPEG pack header (0x000001BA)
MPEG2 transport syncbyte (0x47)
sequence header (0x000001B3)
an audio syncword (0xFFF).
当发现第一个包头时driver立即确定此文件所属mpeg1 还是mpeg2
对于MPEG2 transport stream还要搜索 至少10个MPEG2 transport packets(188bytes,以 0x47开头)

File type analysis
The following rules are only information on reader’s discretion and are subject to changes:
· The extension is not used to determine the file type.
· After opening the input file and reading MPEG data, the FMP driver will search for a MPEG pack header (0x000001BA), for a MPEG2 transport syncbyte (0x47), for a sequence header (0x000001B3) or for an audio syncword (0xFFF). The driver will consider immediately the file as a MPEG1 system file or a MPEG2 program file when a pack header is found. In the case of a MPEG2 transport stream, the driver will try to find at least 10 MPEG2 transport packets (188 bytes length, begin
ning with 0x47). In the last two cases, the diver will keep on searching for a header in order to verify the sequence header or the audio syncword is not inside a packet. When a minimum number of bytes has been looked (around 3000 bytes), the driver will decide whether the file is a video file (first choice) or an audio file (no sequence header has been found).
· When the file is considered as a MPEG1 system file or MPEG2 program system , the driver will start searching for information on the different video and audio streams. When a sequence header is found (there can be more than one to describe the streams), the driver will use it to calculate the number of video and audio streams. then
, the driver will try to retrieve information for those streams in the first 20 packets. If some streams remain not initialized (i.e. declare inside a sequence header, but no matching packets) the driver will keep on looking in the next 80 packets or until the first matching packet is found. If some streams are unknown (i.e. not declare in a sequence header), they will be treated the same way. Note that the driver will stop searching for streams when an invalid packet is found (i.e. the next packet headerdo
es not match with the previous packet header after adding the position of the previous packet and its size).
· When the file is considered as a MPEG2 transport stream, the driver will start searching for a program association table, then
for the program map tables to get the elementary streams. The, the driver will try to retrieve information for the elementary streams by using the random_access_indicator bit.
· When the file is considered as an audio file, the first audio syncword found will be considered as the begin
ning of an audio frame (which may not be true: audio syncword are allowed inside audio data).
· The first packet of a stream is used to determine some of its characteristics. Thus, the first video packet needs to have a sequence header fully contained inside the packet (itdo
es not have to be at the begin
ning of the packet). Same thing for the audio: the first audio syncword found in the packet - there must be at least one - will be considered as the begin
ning of a valid audio frame.


 
多人接受答案了。
 
后退
顶部