Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么截取Rtmp推流的H264/AAC帧数据? #46

Closed
SuperPowerLF2 opened this issue Jul 17, 2019 · 2 comments
Closed

怎么截取Rtmp推流的H264/AAC帧数据? #46

SuperPowerLF2 opened this issue Jul 17, 2019 · 2 comments

Comments

@SuperPowerLF2
Copy link

SuperPowerLF2 commented Jul 17, 2019

详细就是OBS推流到服务器时,我直接在服务器收到RTMP流时做处理,有没有既能知道谁推的流又能获取流的完整帧的位置.

@SuperPowerLF2 SuperPowerLF2 changed the title 我想减少延迟, OBS->SERVER 后直接获取h264的流 我想减少延迟, OBS->SERVER 后直接获取rtmp h264的流 Jul 18, 2019
@xia-chu
Copy link
Member

xia-chu commented Jul 19, 2019

ZLMediaKit处理Rtmp推流的对象是RtmpSession类,该对象具体处理推流音视频rtmp数据的代码如下:

image

上图中_pPublisherSrc变量其实是RtmpToRtspMediaSource类型,我们现在看看RtmpToRtspMediaSource对象的onWrite方法:
image
从上图中我们看到了_rtmpDemuxer变量,该变量是RtmpDemuxer对象,用于解析rtmp包并解复用为H264和AAC。
RtmpToRtspMediaSource派生于RtmpMediaSource对象,除了基类的功能,它还实现了rtmp转rtsp/hls、mp4录制的功能。实现这些功能前都要先解复用成H264和AAC才能实现。所以你可以在RtmpToRtspMediaSource对象中提取到你想要的帧数据,也能知道此处对应的推流来自哪里。

RtmpDemuxer对象是你实现你想要功能的关键,通过RtmpDemuxer::getTracks方法你能获取到音视频的Track对象,Track对象可以提取出譬如sps、pps等信息,也能获取到音视频流。

你可以通过这种方式来截取帧数据并处理:

image

@xia-chu xia-chu changed the title 我想减少延迟, OBS->SERVER 后直接获取rtmp h264的流 怎么截取Rtmp推流的H264/AAC帧数据? Jul 19, 2019
@SuperPowerLF2
Copy link
Author

十分感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants