SPS Values ​​for Stream H 264 on iPhone

Can someone point me to the documentation that will help me get the correct SPS and PPS values ​​for the iPhone.

0
source share
3 answers

The question is a bit unclear ...

Picture Parameter Set described in the latest version of the ITU-T standard publication in chapter 7.3.2.2

Sequence Parameter Set described in chapter 7.3.2.1.

+2
source

I'm sure you know, but you can only save H264 video to a file (.mp4, .mov) on iOS. While there is no access to encoded video frames from the code. Therefore, if you want to create a mp4 file with encoded video, you need to use AVAssetWriter. Apple has some good sample code on how to do this.

I do not know a single place where different SPS / PPS are published; as they vary depending on the compression settings, image size and whether you encode the video in portrait or landscape mode. You can use the above sample code (RosyWriter) to create small .mp4 files with your encoding settings; and then I would use a hex editor to find SPS / PPS manually. Note that SPS / PPS will head to the end of the file after the H264 stream as part of the larger mp4 information structure. You can find more information about your structure on the Internet.

Here are a few SPS / PPS that I found useful for my project. Some of them may work for you, but if you cannot, you can always create mp4 with your H264 encoding settings and find the necessary SPS / PPS. My video was encoded using AVVideoProfileLevelH264Baseline30, and here is the SPS / PPS for the different video sizes that I need:

SPS:

 // For AVCaptureSessionPresetLow(144x192) AVCaptureSessionLandscape on Iphone4S, Iphone5 char iphone_sps[] = {0x67, 0x4D, 0x00, 0x0C, 0xAB, 0x41, 0x82, 0x74, 0xD4, 0x04, 0x04, 0x18, 0x08}; // For AVCaptureSessionPresetLow(144x192), AVCaptureVideoOrientationPortrait on all Ipads char ipad_sps[] = {0x67, 0x4D, 0x00, 0x0C, 0xAB, 0x41, 0x23, 0x34, 0xD4, 0x04, 0x04, 0x18, 0x08}; // Iphone 4G AVCaptureSessionPresetLow (144x192), AVCaptureVideoOrientationPortrait char iphone4g_sps[] = {0x67, 0x42, 0x00, 0x1E, 0x8D, 0x68, 0x24, 0x66, 0x9A, 0x83, 0x00, 0x83, 0x01}; // For AVCaptureSessionPreset352x288 (352x288), AVCaptureVideoOrientationLandscape char iphone_sps[] = {0x67, 0x42, 0x00, 0x1E, 0xAB, 0x40, 0xB0, 0x4B, 0x4D, 0x40, 0x40, 0x41, 0x80, 0x80}; // For AVCaptureSessionPreset352x288 (352x288), AVCaptureVideoOrientationPortrait char ipad_sps[] = {0x67, 0x42, 0x00, 0x1E, 0xAB, 0x40, 0xB0, 0x4B, 0x4D, 0x40, 0x40, 0x41, 0x80, 0x80}; 

PPS:

 char pps[] = {0x28, 0xCE, 0x3C, 0x80}; char iphone4g_pps[] = {0x68, 0xCE, 0x09, 0xC8}; 
+1
source

You can encode one frame into a file, and then extract sps and pps from this file. I have an example that shows how to do this at http://www.gdcl.co.uk/2013/02/20/iOS-Video-Encoding.html

+1
source

Source: https://habr.com/ru/post/946930/


All Articles