2012-05-16 20 views
12

क्या वीडियो के स्क्रीनशॉट लेने के लिए थंबनेल विधि के अलावा कोई अन्य तरीका है? यदि हां तो कृपया मुझे बताएं कि नहीं तो कृपया मुझे बताएं कि एक ही संकल्प के साथ थंबनेल छवि का आकार कैसे बदलें? मैं एक मुद्दा हो रही है, जबकि video.i के स्क्रीनशॉट लेने के लिए इस का इस्तेमाल किया है: -क्या आईफोन में किसी वीडियो का स्क्रीनशॉट लेने के लिए थंबनेल विधि के अलावा कोई अन्य तरीका है?

How to take a screenshot from an video playing through MPMediaPlayerController in iPhone?

इस के बाद मैं एक छवि का इस्तेमाल किया विलय जिसके द्वारा मैं इस Resolution problem

यहाँ

छवि गुणवत्ता हो रही है ve मेरा बड़ा मुद्दा है।

मैं इस

Required Output

मैं केवल वीडियो और एक ही resultion साथ ऊपर स्क्रीनशॉट में दिखाया गया ड्राइंग चाहते हैं। कृपया मदद करें :)

उत्तर

6

थंबनेल विधि के अलावा एक तरीका है जिसके द्वारा मैं एक वीडियो का स्क्रीनशॉट प्राप्त कर सकता हूं। !!!

- (UIImage *)imageFromVideoURL 
{ 
// result 
UIImage *image = nil; 

// AVAssetImageGenerator 
AVAsset *asset = [[AVURLAsset alloc] initWithURL:appDelegate.videoURL options:nil];; 
AVAssetImageGenerator *imageGenerator = [[AVAssetImageGenerator alloc] initWithAsset:asset]; 
imageGenerator.appliesPreferredTrackTransform = YES; 

// calc midpoint time of video 
Float64 durationSeconds = CMTimeGetSeconds([asset duration]); 
CMTime midpoint = CMTimeMakeWithSeconds(durationSeconds/2.0, 600); 

// get the image from 
NSError *error = nil; 
CMTime actualTime; 
CGImageRef halfWayImage = [imageGenerator copyCGImageAtTime:midpoint actualTime:&actualTime error:&error]; 

if (halfWayImage != NULL) 
{ 
    // cgimage to uiimage 
    image = [[UIImage alloc] initWithCGImage:halfWayImage]; 
    [dic setValue:image forKey:kImage]; 
    NSLog(@"Values of dictonary==>%@", dic); 
    NSLog(@"Videos Are:%@",appDelegate.videoURLArray); 
    CGImageRelease(halfWayImage); 
} 
return image; 
} 

लेकिन फिर भी मेरी समस्या एक ही मैं वीडियो मैं नहीं कर सकते ओवरले ड्राइंग के साथ वीडियो के स्क्रीनशॉट पाने पर ड्राइंग हूँ, ताकि के लिए मैं छवियों के विलय का उपयोग करने के ve -:

तरीका यह है।

धन्यवाद :)

2

निम्नलिखित कोड आज़माएं।

moviePlayer = [[MPMoviePlayerController alloc] init]; 
    containerView =[[UIView alloc]initWithFrame:CGRectMake(40,130, 240,219)]; 
    [moviePlayer setContentURL:[NSURL fileURLWithPath:moviePath]]; 
    [[moviePlayer view] setFrame:CGRectMake(0, 0, containerView.frame.size.width, containerView.frame.size.height)]; // frame must match parent view 
    [self.view addSubview:containerView]; 
    [containerView addSubview: [moviePlayer view]]; 
    [moviePlayer setFullscreen:YES animated:YES]; 
2

यह आपको समय आप चाहते हैं के स्थान पर अपना वीडियो प्लेयर की स्क्रीन शॉट दे देंगे। और यह समय विकल्प के साथ प्लेयर के थंबनेल को प्राप्त करने के लिए एक मानक तरीका है।

MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:videoURL]; 
UIImage *thumbnail = [player thumbnailImageAtTime:60.0 timeOption:MPMovieTimeOptionNearestKeyFrame]; 


UIImageView *imagV=[[UIImageView alloc]initWithImage:thumbnail]; 
[imagV setFrame:CGRectMake(self.view.center.x, self.view.center.y, 200.0, 200.0)]; 

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^