Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Video omxplayer AVPacket_Video_Ffmpeg_Decode_H.264_Openmax - Fatal编程技术网

Video omxplayer AVPacket

Video omxplayer AVPacket,video,ffmpeg,decode,h.264,openmax,Video,Ffmpeg,Decode,H.264,Openmax,您好,我正在尝试使用OpenMax组件解码视频,以及来自的hello_视频示例。 我只需编辑video.c并替换AVFormat-read frame包中的“main frame while”即可读取*.h264文件。(我需要读mp4,mov,mkv…)。。 所以,对于test.h264文件和我用ffmpeg生成的其他文件,一切都很好,在屏幕上我可以看到电影 ffmpeg -i file.mp4 -vcodec copy -vbsf h264_mp4toannexb out.h264 但如果我

您好,我正在尝试使用OpenMax组件解码视频,以及来自的hello_视频示例。 我只需编辑video.c并替换AVFormat-read frame包中的“main frame while”即可读取*.h264文件。(我需要读mp4,mov,mkv…)。。 所以,对于test.h264文件和我用ffmpeg生成的其他文件,一切都很好,在屏幕上我可以看到电影

ffmpeg -i file.mp4 -vcodec copy -vbsf h264_mp4toannexb out.h264
但如果我打开test.mp4文件,我就看不到屏幕上的图片,登录控制台会显示数据读取正确,并正确解析到视频解码器的输入缓冲区。 有人能解释一下为什么我在第二次测试时看不到屏幕上的任何东西吗

    do{
    printf("###before DO!\n");
status=av_read_frame(pFormatCtx,&packet);
//only for video
if(packet.stream_index==*video_stream_index){
printf("=>Read frame, status: %d, index: %d, stream index: %d, packet duration: %d, size: %d\n",pstatus,index++,packet.stream_index,packet.duration,packet.size);
int psize=packet.size;
int preaded=0;
double pts=packet.duration;
while(psize!=0){
     buf = ilclient_get_input_buffer(video_decode, 130, 1);
      buf->nFlags = 0;
      buf->nOffset = 0;
      uint64_t val = (uint64_t)(pts == DVD_NOPTS_VALUE) ? 0 : pts;
     if(first_frame==true){buf->nFlags = OMX_BUFFERFLAG_STARTTIME;first_frame=false;}else{buf->nFlags = OMX_BUFFERFLAG_TIME_UNKNOWN;}
buf->nTimeStamp = ToOMXTime(val);
buf->nFilledLen = (psize > buf->nAllocLen) ? buf->nAllocLen : psize;
memcpy(buf->pBuffer, packet.data+preaded,buf->nFilledLen);
psize-=buf->nFilledLen;
preaded+=buf->nFilledLen;
     if(psize == 0){buf->nFlags|=OMX_BUFFERFLAG_ENDOFFRAME;printf("#######################################OMX_BUFFERFLAG_ENDOFFRAME\n");}
printf("=>BUFF size: %d\n",buf->nFilledLen);
OMX_ERRORTYPE r;
if(pstatus==0){if(r=OMX_EmptyThisBuffer(ILC_GET_HANDLE(video_decode), buf) != OMX_ErrorNone){status = -6;printf("Failed, OMX_EmptyThisBuffer, error: 0x%08x , buf allocate: %d, buf lenght: %d \n", r,buf->nAllocLen,buf->nFilledLen);break;}}
}//while psize
av_free_packet(&packet);
   }//if index  
}//do
while(pstatus==0);
登录控制台显示数据已正确读取并正确解析到视频解码器的输入缓冲区

你这是什么意思?最有可能的是,您从mp4解组的数据包不是附录b格式,这是OMX解码器所期望的,也是.h264文件(流)格式的自然形式。因此,在读取一个NALU后,用00000001(四个字节,最后一位打开)替换头,您可能会很幸运

需要考虑的其他事项:解码器可能会也可能不会期望第一个I帧的SPS/PPS,等等


更新:LLVM测试套件有一个可以实现这一点的。您可能还对参考AVC/h264感兴趣,该参考AVC/h264进行相反的转换-从附录B转换为NALU。

您能帮我将数据包转换为附录B格式吗?