为av_read_frame设置超时 [英] Setting a timeout for av_read_frame

查看:46
本文介绍了为av_read_frame设置超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是FFMPEG的新手,正在尝试使用FFMPEG进行HLS流传输.当我尝试使用函数"av_read_frame"时,只要数据不可用,它将返回负值.是否有某种方法可以让此功能等到接收到一些数据或使该功能等到达到超时?

I am new to FFMPEG and was trying to do HLS streaming using FFMPEG. When i tried using the function "av_read_frame" it returns a negative value whenever data is not available. Is there some method to make this function wait till some data is received or to make this function wait till a timeout is reached?

推荐答案

不,实际上没有.如果您查看FFmpeg随附的简单播放器 ffplay.c ,则 read_thread 函数基本上在 av_read_frame 上循环,直到返回非负返回码.如果返回负值,则只需等待10毫秒然后重试.

No, there really isn't. If you look at the simple player ffplay.c which comes with FFmpeg, the read_thread function basically loops on av_read_frame until it returns a non-negative return code. If it returns a negative value, it simply waits for 10ms and retries.

这篇关于为av_read_frame设置超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆