Instagram 비디오 자르기 기능을 구현하려고합니다. 이를 위해 정확한 오리엔테이션 비디오를 올리면 내 MPMoviePlayerController
보기가 올바른 종횡비로 표시되고 사용자는 비디오를 팬 할 수 있고 표시된 정사각형 비디오는 동작시 잘릴 것입니다.PhotoLibrary에서 동영상 오리엔테이션을 올바르게 얻는 방법 iOS
비디오의 올바른 방향을 잡는 데 문제가 있습니다. 나는 다음과 같은 코드를 몇 번 코드의 조각 위에, 세로 실제로 비디오 반대 가로로 분류되고 있다는 점이다 난 데
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:fileUrl options:nil];
NSArray *tracks = [asset tracksWithMediaType:AVMediaTypeVideo];
AVAssetTrack *track = [tracks objectAtIndex:0];
UIInterfaceOrientation orientation =[self orientationForTrack:track];
// method to get orientation
- (UIInterfaceOrientation)orientationForTrack:(AVAssetTrack *)videoTrack
{
CGSize size = [videoTrack naturalSize];
CGAffineTransform txf = [videoTrack preferredTransform];
if (size.width == txf.tx && size.height == txf.ty)
return UIInterfaceOrientationLandscapeRight;
else if (txf.tx == 0 && txf.ty == 0)
return UIInterfaceOrientationLandscapeLeft;
else if (txf.tx == 0 && txf.ty == size.width)
return UIInterfaceOrientationPortraitUpsideDown;
else
return UIInterfaceOrientationUnknown;
}
문제를 사용하고 있습니다. 비디오의 방향이 두 가지 인 경우 (가로 또는 세로) 만 알면됩니다. MPMoviePlayerController
가 해석하고있는 정확한 동일한 방향 값을 원합니다. 내 응용 프로그램은 세로 방향만 지원합니다. 어떤 도움을 주시면 감사하겠습니다.
PS : 위 코드는 아이폰 카메라에서 캡처 한 비디오, whatsapp를 통해 다운로드하거나 공유 한 비디오가 문제를 일으키는 경우 잘 작동합니다.
이 링크는 도움이 될 것입니다. https://gist.github.com/lukabernardi/5020724 –
아니요. 나는이 문제를 해결했고, 나는 약간의 시간을 얻을 때 해결책을 업로드 할 것이다. 당신의 도움을 주셔서 감사합니다. – Usama
확인. 다른 사람이 도움을 얻을 수 있도록 넣어주세요 .... :) –