0

有谁知道如何使用 ffmpeg + Opengl 连续播放视频?因为这只播放一次

tiempo = glfwGetTime();
duracion = 1.0/25.0; // 1 second / 25 fps

while(1){

...        

  if(glfwGetTime() > tiempo + duracion){
    if(av_read_frame(pFormatCtx,&packet) >= 0){
      if(packet.stream_index == 0){
        avcodec_decode_video2(pCodecCtx,pFrame,&frameFin,&packet);
        if(frameFin)sws_scale(img_convert_ctx,pFrame->data,pFrame->linesize,0,pCodecCtx->height,pFrameRGB->data,pFrameRGB->linesize);
      }
      av_free_packet(&packet);
    }
    tiempo += duracion;
  }

...

}

我知道 av_read_frame 函数 (...) 如果文件结束则返回 0。但是如何使函数再次返回零以外的值?o 我怎样才能让视频不断重复?

4

1 回答 1

2

来自documentqtion lavf_decoding.html#ga4fdb3084415a82e3810de6ee60e46a61" > http://ffmpeg.org/doxygen/trunk/group_lavf_decoding.html#ga4fdb3084415a82e3810de6ee60e46a61

0 表示 OK,< 0 表示错误或文件结束

所以如果 <0 然后调用av_seek_frame

返回开始(相同的文档)

于 2013-09-02T22:02:18.050 回答