Can profile-level-id and sprop-parameter-sets be extracted from an RTP stream?

天大地大妈咪最大 提交于 2019-12-21 05:21:55

问题


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.

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.

So my question is:

  1. How can I provide these values to the server maintaining the protocols?
  2. Is there any way to find out these two fields from the RTP stream?

Edit:

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?


回答1:


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

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 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.



来源:https://stackoverflow.com/questions/12338594/can-profile-level-id-and-sprop-parameter-sets-be-extracted-from-an-rtp-stream

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!