[英]Receiving “End of file” while streaming RTSP on iOS
我正在使用ffmpeg库从本地网络中的IP摄像机流式传输RTSP。 流与代码正常工作。
唯一的问题是流似乎会在一段时间后停止。 在进一步调试中,我发现我收到“文件结尾”,这就是循环中断的原因。
while(!playerShouldStop)// && (av_read_frame(pFormatCtx, &pkt1)>=0))
{
int ret = av_read_frame(pFormatCtx, &pkt1);
NSLog(@"av read frame returned = %s",av_err2str(ret));
if(ret >= 0)
{
// process video
}
else
break;
}
日志说
AV读取返回的帧=文件结尾
我下载了Wireshark来检查我得到了什么RTSP数据包,但是那里没有帮助。
首先 ,在直播流中接收EOF是正常的(不应结束)。
其次 ,一次又一次调用av_read_frame()
也avformat_open_input
,但是当我重新启动整个方法(直接从avformat_open_input
)时,它就可以工作。 只是流媒体不流畅并且时不时暂停。
好的...当我使用AVDictionary选项打开流时,似乎没有EOF即可正常工作。
AVDictionary *opts = 0;
int ret = av_dict_set(&opts, "rtsp_transport", "tcp", 0);
// Open video file and read header information into pFormatCtx
if (avformat_open_input(&pFormatCtx, filename, NULL, &opts) != 0)
{
NSLog(@"Error opening video file.");
return;
}
av_dict_free(&opts);
尽管如此,对此进行任何适当的解释还是有帮助的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.