इस कामकाजी कोड को आजमाएं। बस नमूना Buffer के लिए एन्कोडेड CMSampleBufferRef। जबकि encoding.Here मैं तुम्हें एन्कोडिंग विवरण प्रदान कर रहा हूँ
if(!decompressionSession)
{
CMFormatDescriptionRef formatDescription=CMSampleBufferGetFormatDescription(sampleBuffer);
decompressionSession = NULL;
VTDecompressionOutputCallbackRecord callBackRecord;
callBackRecord.decompressionOutputCallback=didDecompress;
callBackRecord.decompressionOutputRefCon = (__bridge void *)self;
OSStatus status1= VTDecompressionSessionCreate(kCFAllocatorDefault, formatDescription, NULL, NULL, &callBackRecord, &decompressionSession);
}
else
{
VTDecodeFrameFlags flags = kVTDecodeFrame_EnableAsynchronousDecompression;
VTDecodeInfoFlags flagOut;
VTDecompressionSessionDecodeFrame(decompressionSession, sampleBuffer, flags, NULL, &flagOut);
VTDecompressionSessionWaitForAsynchronousFrames(decompressionSession);
}
Decompression all back
static void didDecompress(void *decompressionOutputRefCon, void *sourceFrameRefCon, OSStatus status, VTDecodeInfoFlags infoFlags, CVImageBufferRef imageBuffer, CMTime presentationTimeStamp, CMTime presentationDuration){
if(status==noErr)
{
NSLog(@"SUCCESS PROCEED FROM HERE !!!!");
}
}
// ध्यान रखें, आप सही प्रस्तुति समय प्रदान करते हैं ..
//ENCODING-------------------ENCODING---------------ENCODING
if(!_compression_session)
{
NSDictionary* pixelBufferOptions = @{
(NSString*) kCVPixelBufferWidthKey : @(widthOFCaptureImage),
(NSString*) kCVPixelBufferHeightKey : @(heightOFCaptureImage),
(NSString*) kCVPixelBufferOpenGLESCompatibilityKey : @YES,
(NSString*) kCVPixelBufferIOSurfacePropertiesKey : @{}};
_compression_session=NULL;
CFMutableDictionaryRef encoderSpecifications = NULL;
err = VTCompressionSessionCreate(
kCFAllocatorDefault,
widthOFCaptureImage,
heightOFCaptureImage,
kCMVideoCodecType_H264,
encoderSpecifications,
(__bridge CFDictionaryRef)pixelBufferOptions,
NULL,
compressionCallback,
(__bridge void *)self,
&_compression_session);
}
else
{
CMTime presentationTimeStamp = CMSampleBufferGetPresentationTimeStamp(sampleBufferIs);
CVPixelBufferRef pixelbufferPassing= CMSampleBufferGetImageBuffer(sampleBufferIs);
OSStatus status1= VTCompressionSessionEncodeFrame(_compression_session, pixelbufferPassing, presentationTimeStamp, kCMTimeInvalid, NULL, NULL, NULL);
VTCompressionSessionEndPass(_compression_session, NO, NULL);
}
// ENCODING कॉल बैक ------ -----------------------------------
static void compressionCallback(void *outputCallbackRefCon,
void *sourceFrameRefCon,
OSStatus status,
VTEncodeInfoFlags infoFlags,
CMSampleBufferRef sampleBuffer){
}
// शुभकामनाएँ :) खुश कोडिंग :)
क्या आपने प्रलेखन पढ़ा था? क्या आपने इस विषय पर डब्ल्यूडब्ल्यूडीसी वीडियो देखा था? आपने कोशिश क्यों की? – szatmary
मुझे वीडियो और वीडियो स्ट्रीमिंग दुनिया के बारे में पता है। हां मैंने डब्ल्यूडब्ल्यूडीसी 2014 से वीडियो देखा, लेकिन अभी यह पर्याप्त कारण नहीं है क्योंकि मुझे कुछ विवरण याद आते हैं, जो आपके लिए स्पष्ट हो सकता है :) – sivan
ओह, यह मेरे लिए बहुत स्पष्ट है कि आप विवरण खो रहे हैं। असल में आपके पास अपने प्रश्न में इसका उत्तर देने के लिए पर्याप्त विवरण नहीं हैं। आपकी एच 264 स्ट्रीम किस प्रारूप में है? क्या यह अनुबंध बी है? क्या आपके पास एसपीएस/पीपीएस के पॉइंटर्स हैं? – szatmary