gpt4 book ai didi

c++ - ffmpeg + 播放视频循环

转载 作者:太空宇宙 更新时间:2023-11-04 08:53:32 36 4
gpt4 key购买 nike

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

最佳答案

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

0 if OK, < 0 on error or end of file

所以如果 <0 则调用 av_seek_frame

返回开始(同一个文档)

关于c++ - ffmpeg + 播放视频循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18581308/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com