ffmpeg + glfwGetTime()
ffmpeg + glfwGetTime()
本文关键字:glfwGetTime ffmpeg 更新时间:2023-10-16
我尝试使用ffmpeg+opengl来控制视频的播放速度。但我有问题。
我的视频以每秒25帧的速度编码,播放速度非常快。我在代码中添加了这个。
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 = glfwGetTime();
}
...
}
问题是现在视频播放速度比它应该播放的要慢。问题出在哪里?
您将解码图像所需的时间添加到了显示下一个图像所需等待的40ms。此错误是因为您在循环结束时再次测量时间。
而不是:
}
tiempo = glfwGetTime();
}
写入:
}
tiempo+=duraction;
}
我认为这是错误的:if(glfwGetTime()>tiempo+duracion){//。。。tiempo=glfwGetTime();
因为对glfwGetTime的第一个调用和第二个调用不相同->您应该将其缓存在一个变量中并与之进行比较。
相关文章:
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 使用FFMPEG将RGB图像序列保存到.mp4时出现问题
- FFMPEG配置文件级别id大小无效
- FFMpeg库:如何在音频文件中精确查找
- OpenCV RTP-Stream with FFMPEG
- FFmpeg——使用硬件加速进行视频解码
- 如何在 C/C++ 中使用 ffmpeg 的黑框 avfilter
- 在 GLFW 窗口中显示 FFMPEG 解码帧
- FFMPEG:sws_scale返回错误:切片参数 0, 2160 无效
- 为什么有些延迟加载 DLL 会立即使用 FFMPEG 卸载?
- 将FFMpeg AVFrame对象从C++应用程序流式传输到Python的最佳方法?
- 面临分段故障 使用 ffmpeg 读取视频时,因为"pFormatCtx-> streams [i]-> codecpar"的地址0x00
- 将 FFMPEG 帧写入 png/jpeg 文件
- FFMPEG,C++,内存泄漏,我做错了什么?
- 如何在 c++ 中使用 ffmpeg 获取 DirectShow 设备列表?
- 矛盾的未解决的外部符号+未使用的库与VS2017和FFMPEG 4
- FFmpeg av_read_frame从音频流返回数据包
- 使用ffmpeg时如何提高图像导出/提取速度?
- FFmpeg原始视频大小参数
- ffmpeg + glfwGetTime()