[英]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.