【问题标题】:ffmpeg + play video loopffmpeg + 播放视频循环
【发布时间】:2013-09-03 07:17:28
【问题描述】:

有谁知道如何使用 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 我怎样才能让视频不断重复?

【问题讨论】:

    标签: c++ c ffmpeg


    【解决方案1】:

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

    0 表示正常,

    所以如果 av_seek_frame

    返回开始(相同的文档)

    【讨论】:

    • 好朋友!非常感谢。
    • 在正常情况下,您是否需要重置文件阅读器或执行av_seek_frame 之外的任何操作?在大多数情况下,只需调用 av_seek_frame 就足以循环吗?
    猜你喜欢
    • 2013-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-28
    • 2020-08-20
    • 1970-01-01
    相关资源
    最近更新 更多