FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    Package H.264 into FLV format

     

    This article will show how to encapsulate H.264 into FLV format. Between this article, it is recommended to take a look at the following two articles: H.264 code stream structure FLV format detailed First, what do you need to build a FLV file? FLV HEADER + FLV Script Tag + FLV Video Tag + FLV Audio Tag 1 Since it is just the encapsulation H.264, AUDIO TAG is not included. The three parts of the FLV Header + FLV Script Tag + FLV Video Tag will be described below. 1, FLV HEADER By reading the above article "Detailed FLV Format" should be very clear about the content of FLV Header. Below to analyze an example: Signature: 0x46 ('f') Signature: 0x4c ('L') Signature: 0x56 ('V') Version: 01 Flags: 01 TypeflagSReServed [bit 3-7]: 0 Typeflagsaudio [Bit 2]: 0 TypeflagSReServed [bit 1]: 0 Typeflagsvideo [bit 0]: 1 Dataoffset: 00 00 00 00 00 Pretagsize: 00 00 00 00 00 // The first TAG default is 0 1234567891011 2, FLV Script Tag Also known as Metadata Tag, the first TAG behind FLV Header Below to analyze an example Tag header: TagType: 12 (indicating this is a script tag) DataSize: 00 00 9f (the size of the Tag Data section) TimeSTAMP: 00 00 00 (Timestamp of the TAG) TimeStamp_EX: 00 (Extended part of timestamp) Streamid :: 00 00 00 (always 0) 12345 Tag Data: Because tagType is 0x12, this part of the data is two AMF packages The first AMF package: TYPE: 02 (Representing strings) Stringlen: 00 0A (string length is 10) String: 6F 6e 4D 65 74 61 44 61 74 61 (Onmetadata) 123 Second AMF package: TYPE: 08 (represents array) ArrayNum: 00 00 00 07 (number of array elements) Stringlen: 00 08 (First array element string length) String: 64 75 72 61 74 69 6F 6E (DURATION) ValType: 00 (Data Type, Double) VAL: 40 03 70 A3 D7 0A 3D 71 (Double) Stringlen: 00 05 String: 77 69 64 74 68 (WIDTH) ... End: 00 00 00 09 12345678910 pretagsize: 00 00 00 AA 1 3, FLV Video TAG This partially encapsulates image data, that is, the data package of H.264 is here. H.264 is composed of a NALU, NALU types (SPS, PPS, I frame SLICE, non-IF SLICE) The encapsulation H.264 is taken out of these NALUs and then packages into TAG. It should be noted that SPS and PPS must be packaged in a TAG. The following is made to analyze how various NALUs (SPS, PPS, I frame slice, SEI, and non-I frame slice) are encapsulated. 1, SPS and PPS Tag header: Tagtype: 09 (TAG type, including audio (0x08), video (0x09), Script data (0x12)) DataSize: 00 00 2E (the size of the Tag Data section) TimeStamp: 00 00 00 (Timestamp, 19MS) TimeStamp_EX: 00 (Extended part of timestamp) StreamID: 00 00 00 (always 0) 12345 Tag Data: Frametype | CODECID: 17 (KeyFrame | AVC) (parameter of video tag) 1 Avcvideopaket: (because codeciD == 7, thus videodata is avcvideopaket) Avcpakettype: 00 (Type of Acvpacket, 0: AVC Sequence Header; 1: AVC NALU; 2: AVC End of Sequence) CompositionTime: 00 00 00 00 12 (Because acvpakettype == 0, Data = AvcDecoderConfigurationRecord) AvcDecoderConfigurationRecord: CONFIGURATIONVERSION: 01 AVCProfileindication: 64 PROFILE_COMPATIBILITY: 00 Avclevelindication: 1e Lengthsizeminusone: FF Numofsequences: E1 (low five is the number of SPS, the calculation method is: NumofsequenceParameterSets & 0x1f = 1) SequenceParametersetLength: 00 18 (length, 24) SequenceParametersetnalunits: 67 64 00 1E AC D9 40 A0 33 B0 11 00 00 03 02 47 00 6d 34 0F 16 2D 96 (SPS) NumofPictureParameterSets: 01 (number of pps) PictureParametersetLength: 00 06 (length of PPS) PictureParameterSetNalUnalthS: 68 EB E3 CB 22 C0 (PPS) 1234567891011 Previoustagsize: 00 00 00 00 00 1 2, I frame of SLICE Tag header: Tagtype: 09 (TAG type, including audio (0x08), video (0x09), Script data (0x12)) DataSize: 00 35 78 (Size of Tag Data) TimeStamp: 00 00 00 (Timestamp, 19MS) TimeStamp_EX: 00 (Extended part of timestamp) StreamID: 00 00 00 (always 0) 12345 Tag Data: Frametype | CodeCID: 17 (Key Frame | AVC) (Videos TAG parameters) 1 Because codeciD == 7, thw so videodata is AVCVIDEOPAKET Avcvideopaket: AVCPAKETTYPE: 01 (ACVPACKET type, 0: AVC Sequence Header; 1: AVC NALU; 2: AVC End of Sequence) CompositionTime: 00 00 00 00 12 Nalulen: 00 00 35 6F Naludata: ... 12 pretagsize: 00 00 00 00 0035 83 1 The package is the same for the package of the SEI. 3, non IF SLICE The unique package format of non-I frame is basically the same, the only difference is FrameType | CodeCID: section, should be set to: Frametype | CodeCID: 27 (Inter Frame | AVC) (Videos TAG parameters) 1 Summary: The head information of the FLV is explained above, how to encapsulate the Script Tag, and the H.264 different types of NALUs, and release the source code below. GitHub: https://github.com/imsjt/h.264toflv CSDN Download: https://download.csdn.net/download/weixin_42462202/11037715

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us