arjun.a
rename files
6c7b14a
Ticket Name: RTOS/TDA2: how to save encoded h.264 data and play on pc ??
Query Text:
Part Number: TDA2 Tool/software: TI-RTOS my platform is tda2pxx , I had run the usecase "capture > encode > decode > diplay" now I want to record some frames video. so i write the usecase "capture > encode > null_save" , in null_save callback . i save the h.264 data to file . but i can't play it on pc using elecard streameye . the file code.txt is the callback func, i write , is there some wrong ?IDR.txt 0042.code.txt UInt32 idrCnt=0;
static Void capEncFrameCb(System_LinkChInfo *pChInfo, Void *pBuf, Void *arg)
{
System_Buffer *pFrameBuf = (System_Buffer*)pBuf;
System_BitstreamBuffer *pBitFrame;
System_VideoFrameBuffer *pVidFrame;
System_MetaDataBuffer *pMetFrame;
Chains_csi2CalMultiCamAppObj *pObj = (Chains_csi2CalMultiCamAppObj*)arg;
Int32 re=-1;
UInt32 offset;
// BspOsal_semWait(pObj->frameSync, BSP_OSAL_WAIT_FOREVER);
// Vps_printf(" bufType=%d\n",pFrameBuf->bufType);
switch(pFrameBuf->bufType)
{
case SYSTEM_BUFFER_TYPE_VIDEO_FRAME:
Vps_printf(" SYSTEM_BUFFER_TYPE_VIDEO_FRAME\n");
pVidFrame = (System_VideoFrameBuffer*)pFrameBuf->payload;
Vps_printf(" SAVE_ENC_FRAME: Writing frame to file ...length=%d\n",pVidFrame->metaFillLength);
break;
case SYSTEM_BUFFER_TYPE_BITSTREAM:
// Vps_printf(" SYSTEM_BUFFER_TYPE_BITSTREAM\n");
pBitFrame = (System_BitstreamBuffer*)pFrameBuf->payload;
break;
case SYSTEM_BUFFER_TYPE_METADATA:
Vps_printf(" SYSTEM_BUFFER_TYPE_METADATA\n");
pMetFrame = (System_MetaDataBuffer*)pFrameBuf->payload;
Vps_printf(" SAVE_ENC_FRAME: Writing frame to file ...length=%d\n",pMetFrame->metaFillLength);
break;
}
if(TRUE == pObj->encFrame)
{
// Vps_printf(" firstIdrFrame=%d\n",pObj->firstIdrFrame);
if(FALSE == pObj->firstIdrFrame)
{
if(1 == System_Bitstream_Buffer_Flag_Get_Is_Keyframe(pBitFrame->flags))
{
idrCnt++;
Vps_printf(" First IDR frame found Cnt=%d\n",idrCnt);
// if(idrCnt >= 2)
{
pObj->firstIdrFrame = TRUE;
}
}
}
if(TRUE == pObj->firstIdrFrame)
{
Vps_printf(" SAVE_ENC_FRAME: Writing frame to file ...bufsize=%d,length=%d\n",pBitFrame->bufSize,pBitFrame->fillLength);
// re = ChainsCommon_Osal_fileWrite(
// pObj->fp,
// (UInt8*)pBitFrame->bufAddr,
// pBitFrame->fillLength);
// re = Utils_fileWriteFile( fileName11, (UInt8*)pBitFrame->bufAddr, pBitFrame->fillLength);
re = User_fileWrite( pObj->fp, (UInt8*)pBitFrame->bufAddr, pBitFrame->fillLength);
offset = 5;
Vps_printf(" offset = %d, data0-5=%x,%x,%x,%x,%x\n",
offset,
*((UInt8*)pBitFrame->bufAddr+offset),
*((UInt8*)pBitFrame->bufAddr+offset+1),
*((UInt8*)pBitFrame->bufAddr+offset+2),
*((UInt8*)pBitFrame->bufAddr+offset+3),
*((UInt8*)pBitFrame->bufAddr+offset+4));
Vps_printf(" SAVE_ENC_FRAME: Writing Encode frame to file DONE,return = %d,Frame ID=%d\n",re,pFrameBuf->frameId);
// pObj->encFrame = FALSE;
BspOsal_semPost(pObj->frameSync);
}
// pObj->encFrame = FALSE;
}
} the file IDR.txt is idr h264 data, can you help me to check if the data is right ? i checked many frames , the start code of each frame is 00 00 00 01 , there is no other nalu type, why?
Responses:
Hi This file dump and playing with VLC media player is already validated For the Null link file write set below configuration. pUcObj->NullPrm.dumpDataType = NULL_LINK_COPY_TYPE_FILE; strcpy(pUcObj->NullPrm.nameDataFile[0], "stream.h264"); I assume you use VSDK 3.3 release regards, Shiju