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

NAL packaging #41

Closed
pzs7602 opened this issue May 22, 2016 · 2 comments
Closed

NAL packaging #41

pzs7602 opened this issue May 22, 2016 · 2 comments

Comments

@pzs7602
Copy link

pzs7602 commented May 22, 2016

I’m newbie in the field of video streaming, please help me to understand your code in method sampleOutput(video sampleBuffer: CMSampleBuffer) in RTMPMuxer.swift:

  1. data in buffer is formed by a header and encoded video data got from CMBlockBuffer in the CMSampleBuffer.
  2. the header is 5 bytes in length, byte[0] is either 0x17(if it’s a keyframe) or 0x27(if it’s not a keyframe)
  3. byte[1] is 1(NAL type)
  4. I watched from debug window that byte[2]..byte[4] is always 0x000000
  5. so I get every buffer data(in hex):
    1701000000 followed by encoded H264 video data
    or
    2701000000 followed by encoded H264 video data
    I know that the encoded video buffer should be converted to NALU before sent to stream,the NALU should be Annex B(3 or 4 bytes start code in header) or AVCC(4bytes in length in header) type. so I donnt understand why the 5 bytes header be added before the encoded H264 video data, would you please to explain this to me? thank you very mush!
@shogo4405
Copy link
Owner

shogo4405 commented May 22, 2016

see also section VIDEODATA[p.9] and AVCVIDEOPACKET[p.10] https://www.adobe.com/content/dam/Adobe/en/devnet/flv/pdfs/video_file_format_spec_v10.pdf

  • First byte
    • FrameType UB[4] 0b11110000
    • CodecID UB[4] 0b00001111
  • Second Byte
    • AVCPacketType UI8
  • 3rd - 5th Bytes
    • CompositionTime SI24

@shogo4405
Copy link
Owner

if you have no questions.
please close this isuue.

Regards.

@pzs7602 pzs7602 closed this as completed May 23, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants