是否可以从RTP流中提取概要文件级别ID和属性参数集? [英] Can profile-level-id and sprop-parameter-sets be extracted from an RTP stream?

查看:115
本文介绍了是否可以从RTP流中提取概要文件级别ID和属性参数集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将实时视频从我的Android手机流式传输到PC上的台式机RTSP服务器.可以在另一台设备上播放流式视频.我使用的是H.264视频编码器,因此服务器返回的SDP(作为DESCRIBE请求的答复)应包含profile-level-idsprop-parameter-sets字段.

I'm trying to stream live video from my android phone to a desktop RTSP server on my PC. The streamed video can be played in another device. I'm using H.264 video encoder, so the SDP returned by the server (as the reply of DESCRIBE request) should contain the profile-level-id and sprop-parameter-sets fields.

Spydroid 项目显示了如何从记录到其中的虚拟文件中提取这些信息通过解析SD卡(来自avcC块).但是我不能那样做.在Spydroid中,媒体记录器和RTSP服务器位于同一设备上,因此服务器在流式传输之前始终可以使用与记录器相同的配置记录测试文件.但是我将视频作为RTP流直接从手机流式传输到远程服务器.

The Spydroid project shows how to extract these info from a dummy file recorded to SD card by parsing it (from the avcC block). But I cannot do it like that. In Spydroid, the media recorder and the RTSP server are on the same device, so the server can always record a test file with the same configuration as the recorder before streaming. But I'm streaming the video directly from the phone to the remote server as an RTP stream.

所以我的问题是:

  1. 如何向维护协议的服务器提供这些值?
  2. 有什么方法可以从RTP流中找出这两个字段吗?

我正在使用Android手机生成流,但是服务器可以从任何来源接收RTP流.那么,有没有通用的方法来获取这些值?

I'm using android phones to generate the streams, but the server can receive RTP stream from any source. So, is there any generic way to get these values?

推荐答案

您可以从序列参数集NAL单元中提取profile-level-id(实际上,如果甚至在流中发送了参数集), NAL标头后的前3个字节.即来自级别为3.0的基线配置文件"流中SPS NAL单元的前四个字节如下所示:

You can extract the profile-level-id from the Sequence Parameter Set NAL Unit (if, in fact, the parameter sets are even being sent in the stream), it's the first 3 bytes after the NAL header. i.e. the first four bytes of the SPS NAL unit from a Baseline Profile stream with level 3.0 would look like this:

67 42 00 1E

忽略第一个字节,这仅表示它是一个SPS NAL单元(0x67 & 0x1F == 0x7 SPS是NAL 7类,PPS是NAL 8类).其他3个字节为您提供配置文件,约束标志和级别(实际上,它只是级别乘以第3个字节中的10).

Disregard the first byte, this just indicates that it is an SPS NAL Unit (0x67 & 0x1F == 0x7 SPS is NAL Type 7, PPS is NAL Type 8). The other 3 bytes give you the profile, constraint flags, and level (in fact, it's simply level times 10 in the 3rd byte).

sprop-parameter-sets是Base64编码的序列参数集和图片参数集,以逗号分隔.因此,只需Base64对SPS和PPS NAL单元(Nal类型7和NAL类型8)进行编码,并以逗号分隔即可.

sprop-parameter-sets is the Base64 encoded Sequence Parameter Sets and Picture Parameter Sets, separated by commas. So just Base64 encode the SPS and PPS NAL Units (Nal type 7 and NAL type 8) and separate by comma and you should be good to go.

这篇关于是否可以从RTP流中提取概要文件级别ID和属性参数集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆