-
Notifications
You must be signed in to change notification settings - Fork 33
Mp4 video playback capability on all the default players for videos having H.264 frames
To play Mp4 videos containing h.264 frames on all default players of the OS, The default Annex B format of H.264 bitstream should be converted to Mp4 format. General H.264 bitstream is as follows,
- I frame with prepended sps and pps data:
- 00 00 00 01 67 ..(sps data)...00 00 00 01 68 .. (pps data).. 00 00 00 65 ..(I frame data)...!
- The sps data starts from 67, pps data starts from 68 and I frame starts from 65.
- I frame or P frame data:
- 00 00 00 65 ..(I frame data) .. [I frame data starts from 65]
- 00 00 00 61 ..(P frame data) .. [P frame data starts from 61]
Converting H.264 bitstream to Mp4 format:
-
As given above every sps, pps , I frame and P frame is prepended with 4 bytes of nalu seprator (00 00 00 01).
-
The nalu separators of sps and pps data should be changed i.e. the last byte of nalu separtor should contain its size - 00 00 00 spsSize(4th byte) 67 .. (sps data).. 00 00 00 ppsSize(4th byte) 68 .. (pps data)..
-
For I frame or P frame all the 4 bytes of nalu separators should be used to save the frame's size. size size size size 65 .. (I frame data) .. size size size size 61 .. (P frame data) ..
naluData[0] is set to the most significant byte (byte 3) of the 32-bit integer. naluData[1] is set to the second most significant byte (byte 2). naluData[2] is set to the third most significant byte (byte 1). naluData[3] is set to the least significant byte (byte 0).