简体   繁体   English

H264基本流格式混乱

[英]H264 elementary stream format confusion

I've become confused on the format for H264 video streams. 我对H264视频流的格式感到困惑。 Put simply I've read from ISO spec and other sources both that H264 NAL units are delimited by a start code and contain no length information AND that they don't have a start codes and are led by 4 bytes (I know this can vary) giving the length of the NAL unit. 简单地说,我从ISO规格和其它来源的是H264 NAL单元由起始码界定,并且不包含任何长度的信息他们没有起始码和4个字节导致阅读(我知道这可以改变)给出NAL单位的长度。 To make matters more confusing I've been looking at code in Spydroid and it appears to address both scenarios. 为了让事情更加混乱,我一直在寻找Spydroid中的代码,它似乎解决了这两种情况。 Are there two different formats that I'm getting mixed up and if so could anyone direct me to information explaining the two. 有两种不同的格式,我混淆了,如果是这样,任何人都可以指导我解释这两种格式的信息。

Background 背景

To give some background in case it helps I'm working on doing live streaming from Android cameras. 给出一些背景知识,以帮助我从Android摄像头进行直播。 The stream will either be split up on device for RTP or sent as the raw MP4 data to be split on a server. 流将在设备上拆分为RTP,或作为原始MP4数据发送,以便在服务器上拆分。 Either way the stream will be live so there will be no MOOV info to find the audio and video frames. 无论哪种方式,流都将是实时的,因此没有MOOV信息可以找到音频和视频帧。 I believe I have much of the project figured out but I'm basically confused on what it is I should be seeing in the H264 stream. 我相信我已经找到了很多项目,但我对H264流中应该看到的内容感到困惑。 If the length is indeed included in the NAL unit it would definitely help me. 如果长度确实包含在NAL单位中,那肯定对我有帮助。

As far as H.264 bitstream is concerned. 就H.264比特流而言。 it is split up into NAL units, separated by startcode prefix. 它被分成NAL单元,由startcode前缀分隔。 ie

startcode_prefix  NALUnit    startcode_prefix  NALUnit .....  

There is no length information in it because it is a bitstream. 其中没有长度信息,因为它是比特流。 You have to look for startcode pattern (0x000001 OR 0x00000001) in the bitstream for the next NAL unit. 您必须在下一个NAL单元的比特流中查找起始码模式(0x000001或0x00000001)。

More information here: H264 parsing - slice header detection 更多信息: H264解析 - 切片头检测

According to the following link there are H.264 subtypes. 根据以下链接,存在H.264子类型。 Some have start codes in stream and others have 1, 2 or 4 byte length fields. 一些具有流中的起始码,而另一些具有1,2或4个字节长度的字段。

http://msdn.microsoft.com/en-us/library/windows/desktop/dd757808(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/windows/desktop/dd757808(v=vs.85).aspx

So it looks like I will need to do a check for subtype to determine how to parse the stream. 所以看起来我需要检查子类型以确定如何解析流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM