【发布时间】:2011-10-09 20:34:44
【问题描述】:
我正在尝试从我从 YouTube 获得的 RTSP 流中读取视频帧。这是我的测试视频的链接:
rtsp://v8.cache5.c.youtube.com/CiILENy73wIaGQkJlrXMiAG8BxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp
如果我正在从本地文件中读取帧 - 一切都很好,但是当从流中读取它们时,我只会得到很多工件。我搜索了一下,发现 UDP 数据包可能存在问题,切换到 TCP 可能会有所帮助,但我真的找不到可以更改的地方。
这是读取帧的函数:
bool nextFrame(AVFormatContext *pFormatCtx, AVCodecContext *pCodecCtx, int videoStream, AVFrame *pFrame) { AVPacket packet;
int frameFinished = 0;
while( !frameFinished && av_read_frame(pFormatCtx, &packet) >= 0 ) {
// Is this a packet from the video stream?
if( packet.stream_index == videoStream ) {
// Decode video frame
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
}
// Free the packet that was allocated by av_read_frame
av_free_packet(&packet);
}
return frameFinished!=0;
}
我的日志中也收到很多错误消息:
[h263 @ 0x7804c00] warning: first frame is no keyframe
[h263 @ 0x7804c00] illegal ac vlc code at 6x1
[h263 @ 0x7804c00] Error at MB: 18
[h263 @ 0x7804c00] concealing 99 DC, 99 AC, 99 MV errors
[h263 @ 0x7804c00] I cbpy damaged at 10 4
[h263 @ 0x7804c00] Error at MB: 58
[h263 @ 0x7804c00] concealing 99 DC, 99 AC, 99 MV errors
[h263 @ 0x7804c00] I cbpy damaged at 6 6
[h263 @ 0x7804c00] Error at MB: 78
[h263 @ 0x7804c00] concealing 76 DC, 76 AC, 76 MV errors
[h263 @ 0x7804c00] I cbpy damaged at 5 5
[h263 @ 0x7804c00] Error at MB: 65
[h263 @ 0x7804c00] concealing 88 DC, 88 AC, 88 MV errors
[h263 @ 0x7804c00] illegal ac vlc code at 7x5
[h263 @ 0x7804c00] Error at MB: 67
[h263 @ 0x7804c00] concealing 86 DC, 86 AC, 86 MV errors
...等等
编辑:这 99.9% 是 UDP-TCP 问题。我找到了这个链接:
rtsp://195.200.199.8/mpeg4/media.amp
这是一些在线提供的测试相机。它与工件一起流动。但是,如果它有获取参数'tcp'并且我使用它
rtsp://195.200.199.8/mpeg4/media.amp?tcp
一切正常,无需人工制品。
所以纠正我的问题:有什么方法可以强制 YouTube 或 ffmpeg 使用 TCP 吗?
【问题讨论】:
-
你使用什么函数来打开到 url 的连接?你写过自己的 URLContext 吗?
-
@JConway 我只是使用标准的 avformat_open_input 和 URL 作为路径
标签: iphone youtube ffmpeg gdata-api rtsp