媒体基金会:当 GOV 长度大于 1 时,来自摄像机的 mpeg4 流会失真

发布于 2025-01-07 04:14:26 字数 1182 浏览 4 评论 0原文

我在客户端使用 Media Foundation 通过 RTSP 服务器显示来自 AXIS 摄像机的实时 mpeg4 流。

如果我设置 GOV @camera = 1,即相机只会发送 I 帧,则客户端视频工作得很好。但是,如果 GOV 增加并且摄像机也开始发送 P 帧,我的视频会定期突然失真。我不能总是设置 GOV = 1,因为它会消耗大量带宽。

以下是 RequestSample 方法的代码,其中我向 Media Foundation 提供样本:

RTPFrame frame = null;
byte[] frameBytes = null;

frame = _VideoJitter.GetNextFrame();
frameBytes = frame.GetFrameAsBytes();
frame.FrameType= RTPFrame.PredictFrameType(frameBytes);

_videoEncapsulatedSample.ReadSampleFrom(frameBytes);
videoSample = _videoEncapsulatedSample.MfSample;

long timestamp = nextSampleTimestamp ?? 0;   

videoSample.SetSampleTime(timestamp);
duration_video = (long)GetPresentationTime(frame);

videoSample.SetSampleDuration(duration_video);
nextSampleTimestamp = timestamp + duration_video;

if (frame.FrameType == FrameType.IFrame)
{
videoSample.SetUINT32(MFAttributesClsid.MFSampleExtension_CleanPoint, 1);
}

return videoSample;

我需要设置任何属性来处理 P 帧吗?

任何帮助将不胜感激......

更新(2012/02/22):

我运行了一些统计数据,发现有时 I 帧永远不会到达客户端,即假设 GOV = 15,所以每个第 15 帧应该是 I 帧,但有时(以不规则的间隔)客户端会在 28、30 或 59 个 P 帧之后收到 I 帧。

有什么指点吗??

谢谢,

普拉泰克

I am using Media Foundation on client side to display live mpeg4 stream from AXIS Camera through RTSP server.

Client side video works very fine if i set GOV @ camera = 1, i.e. camera will only send I-Frames. But if GOV is increased and camera starts sending P-Frames also, my video suddenly gets distorted at regular intervals. I cannot set GOV = 1 for always because it consumes a lot of bandwidth.

Following is the code for RequestSample method where i supply Samples to Media Foundation :

RTPFrame frame = null;
byte[] frameBytes = null;

frame = _VideoJitter.GetNextFrame();
frameBytes = frame.GetFrameAsBytes();
frame.FrameType= RTPFrame.PredictFrameType(frameBytes);

_videoEncapsulatedSample.ReadSampleFrom(frameBytes);
videoSample = _videoEncapsulatedSample.MfSample;

long timestamp = nextSampleTimestamp ?? 0;   

videoSample.SetSampleTime(timestamp);
duration_video = (long)GetPresentationTime(frame);

videoSample.SetSampleDuration(duration_video);
nextSampleTimestamp = timestamp + duration_video;

if (frame.FrameType == FrameType.IFrame)
{
videoSample.SetUINT32(MFAttributesClsid.MFSampleExtension_CleanPoint, 1);
}

return videoSample;

Do i need to set any attribute for processing P-Frames??

Any help would be highly appreciated....

Update (2012/02/22) :

I ran some statistics and found that some times I-frames never reach client, i.e. suppose GOV = 15, so every 15th frame should be an I-Frame, but sometimes (at irregular intervals) client receives an I-Frame after 28 or 30 or 59 P-frames.

Any pointers ??

Thanks,

Prateek

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文