I tried below code to convert video from ALAsset
to NSData
, this NSData
is submitting to the server correctly.
Problem:
But the problem is when I get the thumbnail from NSData in the server, the image is not oriented correctly for some videos and showing correctly for other videos. Also i feel that Video also not oriented correctly.
So do I have to include any thing extra in my code. I know how to orient Image but I don't know how to orient correctly a video.
-(NSData *)ConvertVideoToNSData:(ALAsset *)asset{
NSData *VideoData;
ALAssetRepresentation *rep = [asset defaultRepresentation];
Byte *buffer = (Byte*)malloc(rep.size);
NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:rep.size error:nil];
VideoData = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];
return VideoData;
}
Try with
CGSize dimesions = [representation dimensions];
if (dimesions.height > dimesions.width)
orientation = 1; //Portrait
else
orientation = 0; //Lanscape
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.