2012-01-16 5 views
5

में डीकोडिंग एच 264 मैं एवीफाउंडेशन और डिकोडिंग प्रक्रिया में नौसिखिया हूं। मुझे एच 264 वीडियो फ़ाइल को डीकोड करने और इसे आईफोन में चलाने की जरूरत है ... क्या कोई मुझे ऐसा करने के लिए दिशानिर्देश दे सकता है।आईओएस

मैं ऐसा करने के लिए ffmpeg या किसी तीसरे पक्ष की लाइब्रेरी का उपयोग नहीं करना चाहता हूं। जहाँ तक मुझे AVFoundation एन्कोडिंग का उपयोग पता है के रूप में संभव है ... यहाँ कोड है जो मैंने सोचा है एन्कोडिंग के लिए नहीं बल्कि बिल्कुल यकीन है कि प्रयोग किया जाता है ...

float bitsPerPixel; 
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(currentFormatDescription); 
int numPixels = dimensions.width * dimensions.height; 
int bitsPerSecond; 

// Assume that lower-than-SD resolutions are intended for streaming, and use a lower bitrate 
if (numPixels < (640 * 480)) 
    bitsPerPixel = 4.05; // This bitrate matches the quality produced by AVCaptureSessionPresetMedium or Low. 
else 
    bitsPerPixel = 11.4; // This bitrate matches the quality produced by AVCaptureSessionPresetHigh. 

bitsPerSecond = numPixels * bitsPerPixel; 

NSDictionary *videoCompressionSettings = [NSDictionary dictionaryWithObjectsAndKeys: 
              AVVideoCodecH264, AVVideoCodecKey, 
              [NSNumber numberWithInteger:dimensions.width], AVVideoWidthKey, 
              [NSNumber numberWithInteger:dimensions.height], AVVideoHeightKey, 
              [NSDictionary dictionaryWithObjectsAndKeys: 
              [NSNumber numberWithInteger:bitsPerSecond], AVVideoAverageBitRateKey, 
              [NSNumber numberWithInteger:30], AVVideoMaxKeyFrameIntervalKey, 
              nil], AVVideoCompressionPropertiesKey, 
              nil]; 
if ([assetWriter canApplyOutputSettings:videoCompressionSettings forMediaType:AVMediaTypeVideo]) { 
    assetWriterVideoIn = [[AVAssetWriterInput alloc] initWithMediaType:AVMediaTypeVideo outputSettings:videoCompressionSettings]; 
    assetWriterVideoIn.expectsMediaDataInRealTime = YES; 
    assetWriterVideoIn.transform = [self transformFromCurrentVideoOrientationToOrientation:self.referenceOrientation]; 
    if ([assetWriter canAddInput:assetWriterVideoIn]) 
     [assetWriter addInput:assetWriterVideoIn]; 
    else { 
     NSLog(@"Couldn't add asset writer video input."); 
     return NO; 
    } 
} 
else { 
    NSLog(@"Couldn't apply video output settings."); 
    return NO; 
} 

return YES; 

मैं इस बारे में पूरी तरह से अनुभवहीन हूँ, मदद करें .. .from जहां शुरू करने के लिए ///

धन्यवाद

+0

मैं वही काम करने की कोशिश कर रहा हूं जो आपको समाधान मिल रहा है? –

+0

परियोजना रद्द कर दी गई थी ... हमें समाधान नहीं मिला ... –

उत्तर

0

सरल समाधान MPMoviePlayerController उपयोग करने के लिए है। यह एक mov या mv4 फ़ाइल इनपुट (स्थानीय फ़ाइल सिस्टम से या एक यूआरएल के माध्यम से) लेता है।

दूसरा विकल्प AVPlayer क्लास का उपयोग करना है।

आशा है कि यह मदद करता है,

डेविड

0

आप देखें और आधिकारिक नमूना कोड का निर्माण कर सकते हैं: देखने के लिए यह कैसे काम करता AVPlayerDemo। यह एवी फाउंडेशन फ्रेमवर्क का उपयोग करता है, मुख्य रूप से एवीप्लेयर एपीआई वीडियो फ़ाइलों को चलाने के लिए और प्रदर्शन उत्कृष्ट है। AVPlayerDemo द्वारा एक वीडियो फ़ाइल चलाने के लिए आपको वीडियो फ़ाइलों को आईट्यून्स द्वारा अपने आईओएस डिवाइस पर कॉपी करना चाहिए और AVPlayerDemo ऐप पर आईपॉड लाइब्रेरी का चयन करना चाहिए।