Can someone point me to documentation that will help me get correct SPS and PPS values for iPhone.
问题:
回答1:
Question is a bit unclear...
Picture Parameter Set
is described in the latest ITU-T release of the standard in chapter 7.3.2.2
Sequence Parameter Set
is described in chapter 7.3.2.1.
回答2:
You can encode a single frame to a file and then extract the sps and pps from that file. I have an example that shows how to do exactly that at http://www.gdcl.co.uk/2013/02/20/iOS-Video-Encoding.html
回答3:
I am sure you know, but you can only save H264 encoded video into a file(.mp4, .mov) on iOS. There is no access to encoded video frames from code yet. So if you want to create an mp4 file that has encoded video, you need to use AVAssetWriter. Apple has a good example code on how to do this.
I don't know of any place where different SPS/PPS are published; since they vary based on your compression settings, image size, and whether you are encoding video in portrait or landscape mode. You can use above example code(RosyWriter) to generate some small .mp4 files with your encoding presets; and then I would use a hex editor to find the SPS/PPS manually. Note that SPS/PPS will towards on the end of the file after your H264 stream as part of a larger mp4 info structure. You can find more info on its structure online.
Here is some SPS/PPS that I found useful for my project. Some of them might work for you, but if not you can always generate an mp4 with your H264 encoding presets and find necessary SPS/PPS. My video was encoded using AVVideoProfileLevelH264Baseline30, and here are the SPS/PPS for different video sizes I needed:
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};