hpdell 发表于 2018-8-22 09:56:48

请教下,播放avi如何实现快进退啊 ???

请教下,播放avi如何实现快进退啊 ???

自己捣鼓了了一下,没有成功,代码如下:

void AVI_TimeSet(FIL *_pFile, VideoPlayCtrlRTOS   *_VideoPlayCtrl)
{
        uint32_t fpos = _pFile->fptr;
uint32_t uiPos = 0;
        uint32_t BytesRD = 0;
        uint32_t offset = 0;
        uint8_t*tempbuf = 0;
        uint8_t*pbuf = 0;

        uiPos = (_pFile->obj.objsize / _VideoPlayCtrl->Totsec) * g_tWav.uiCurTime;//每次前进 g_tWav.uiCurTime 秒钟的数据量
        tempbuf   = mymalloc(SRAMEX,   AVI_MAX_SIZE);          // 申请视频buf 120KByte or 1MB
       
        while(1)
        {
                if(fpos < _pFile->obj.objsize)
                {
                        fpos += uiPos;
                        if(fpos > (_pFile->obj.objsize - AVI_MAX_SIZE))
                        {
                                fpos = _pFile->obj.objsize - AVI_MAX_SIZE;
                        }       
                }
                else
                {
                        if(fpos > uiPos)
                                fpos -= uiPos;
                        else
                                fpos=0;        
                }
                f_lseek (_pFile, fpos);      //偏移到数据开始的地方

                if(fpos == 0)
                        AVI_GetFrame(&AVI_Handel, _pFile);   //从 0 开始寻找, 这个测试 ok
                else
                {

                        pbuf = tempbuf;
                        f_read(_pFile, pbuf, AVI_MAX_SIZE, (UINT*)&BytesRD );
                        pbuf = tempbuf;
                        offset = __AVI_SearchID(pbuf,AVI_MAX_SIZE, AVI_Handel.aviInfo.VideoFLAG);   //寻找视频帧
                       
                        // Read first Frame info
                        __AVI_GetStreamInfo( &AVI_Handel, pbuf + offset );//获取流信息
                       
                        if(AVI_Handel.aviInfo.StreamID == AVI_VIDS_FLAG)//显示帧
                        {
                                // go to the first frame offset in the avi file
                                f_lseek(_pFile,fpos + offset);//偏移到流数据开始处
                               
                                  // Get the current frame size
                                AVI_Handel.FrameSize = AVI_Handel.aviInfo.StreamSize;
                               
                                break;
                        }
                        else if(AVI_Handel.aviInfo.StreamID == AVI_AUDS_FLAG)
                        {
                                // go to the first frame offset in the avi file
                                f_lseek(_pFile,fpos + offset);//偏移到流数据开始处
                               
                                  // Get the current frame size
                                AVI_Handel.FrameSize = AVI_Handel.aviInfo.StreamSize;
                               
                                break;
                        }
                }
        }
        myfree(SRAMEX, tempbuf);                //释放内存
}


经过上面查找后,进入正常播放状态,貌似只能够 播放一帧,后续识别到的

AVI_Handel.aviInfo.StreamID这个数据流的值为 0???????????????????

feixiang20 发表于 2018-8-23 00:03:40

循环语句里参数值没有改变么,检查偏移是不是对

hpdell 发表于 2018-8-23 10:47:01

feixiang20 发表于 2018-8-23 00:03
循环语句里参数值没有改变么,检查偏移是不是对

循环播放里面,如果我不使用 快进退功能,播放是完全没有问题的啊,

循环播放里面是有进行偏移的
页: [1]
查看完整版本: 请教下,播放avi如何实现快进退啊 ???