Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way other than thumbnail method to take a screenshot of an video in Iphone?

Is there any way other than thumbnail method to take a screenshot of an video? If yes then please tell me if not then please tell me how to resize an thumbnail image with a same resolution? i have getting an issue while taking screenshot of video.i have used this:-

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

After this i ve used merging of an image by which i'm getting thisResolution problem

here image quality is my big issue.

I want this

Required Output

I want only video and drawing shown in above screenshot with same resultion. Please help Thanks :)

like image 405
Nikhil Bansal Avatar asked May 16 '12 05:05

Nikhil Bansal


People also ask

How do I change the screenshot settings on my iPhone?

On the “Touch Settings” screen, scroll down until you see the “Back Tap” option, then tap it. In “Back Tap” settings, you have a choice of assigning the screenshot action to either two taps (“Double Tap”) or three taps (“Triple Tap”) on the back of the case.

How do you screenshot on iPhone without power button?

Launch Settings on your iPhone and go to Accessibility. Tap Touch and scroll down to select Back Tap. You will have two options here, Double Tap and Triple Tap; select the option you prefer. Now, choose Screenshot from the given list of options.


2 Answers

There is a way other than thumbnail method by which i can get screenshot of a video.!!!

The way is this :-

- (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;
}

But still my problem is same i m drawing on video i cant get video's screenshot with drawing overlay,so for that i ve to use merging of images.

Thanks :)

like image 54
Nikhil Bansal Avatar answered Nov 01 '22 15:11

Nikhil Bansal


Try the following code.

    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];
like image 31
Raj Subbiah Avatar answered Nov 01 '22 15:11

Raj Subbiah