title: ffmpeg + play video loop
body: <p>Does anyone know how to make a video using ffmpeg + Opengl play continuously?. Because this is only played once</p>
  
  <pre><code>tiempo = glfwGetTime();
  duracion = 1.0/25.0; // 1 second / 25 fps
  
  while(1){
  
  ...        
  
    if(glfwGetTime() &gt; tiempo + duracion){
      if(av_read_frame(pFormatCtx,&amp;packet) &gt;= 0){
        if(packet.stream_index == 0){
          avcodec_decode_video2(pCodecCtx,pFrame,&amp;frameFin,&amp;packet);
          if(frameFin)sws_scale(img_convert_ctx,pFrame-&gt;data,pFrame-&gt;linesize,0,pCodecCtx-&gt;height,pFrameRGB-&gt;data,pFrameRGB-&gt;linesize);
        }
        av_free_packet(&amp;packet);
      }
      tiempo += duracion;
    }
  
  ...
  
  }
  </code></pre>
  
  <p>I know av_read_frame function (...) returns 0 if the end of file. But how do I make the function again returns a value other than zero? o How I can I make the video is constantly repeated?</p>