ffmpeg +播放视频循环

时间:2013-09-02 21:58:57

标签: c++ c ffmpeg

有没有人知道如何使用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如何让视频不断重复?

1 个答案:

答案 0 :(得分:2)

来自documentqtion lavf_decoding.html#ga4fdb3084415a82e3810de6ee60e46a61“> http://ffmpeg.org/doxygen/trunk/group_ lavf _decoding.html#ga4fdb3084415a82e3810de6ee60e46a61

  

0如果OK,<错误或文件结尾时为0

所以如果< 0则调用av_seek_frame

返回开始(同一个文档)

相关问题