BradLarson / GPUImage

An open source iOS framework for GPU-based image and video processing
http://www.sunsetlakesoftware.com/2012/02/12/introducing-gpuimage-framework
BSD 3-Clause "New" or "Revised" License
20.24k stars 4.61k forks source link

VideoFilter - video orientation is always landscape #2546

Closed Sumit-2singh closed 6 years ago

Sumit-2singh commented 6 years ago

Hi @BradLarson , I'm having trouble understanding how GPUImageMovie/GPUImageView orientation works. I modify the SimpleVideoFileFilter example to load video using UIImagePickerController so I can test various kind of videos. And no matter witch video I loaded (portrait, landscape, upsideDown) the result was always a landscape orientation video.

below is my code This Code For Camera Orientation [func checkOrientationForVideo(assets:AVAsset){ let orientation = assets.video_orientation if (orientation == .landscapeLeft){ kVCOrientation = .Landscap let value = UIInterfaceOrientation.landscapeLeft.rawValue UIDevice.current.setValue(value, forKey: "orientation") } else if (orientation == .landscapeRight){ kVCOrientation = .LandscapRight let value = UIInterfaceOrientation.landscapeRight.rawValue UIDevice.current.setValue(value, forKey: "orientation") } else if (orientation == .portraitUpsideDown || orientation == .portrait){ kVCOrientation = .Protrait let value = UIInterfaceOrientation.portrait.rawValue UIDevice.current.setValue(value, forKey: "orientation") } switch kVCOrientation { case .Landscap: self.videoCamera?.outputImageOrientation = .landscapeLeft break; case .LandscapRight: self.videoCamera?.outputImageOrientation = .landscapeRight; break; case .Protrait: self.videoCamera?.outputImageOrientation = .landscapeLeft; break; case .All: self.videoCamera?.outputImageOrientation = .portrait; break; } UIViewController.attemptRotationToDeviceOrientation() }]

and the second one is for FilterView

if SelectedMedia.sharedInstance.selectedMedia.isImage == false { self.checkOrientationForVideo(assets: SelectedMedia.sharedInstance.selectedMedia.videoAssets)
switch kVCOrientation { case .Landscap: self.filterView?.setInputRotation(.noRotation, at: 0) case .LandscapRight: self.filterView?.setInputRotation(.noRotation, at: 0) case .Protrait: self.filterView?.setInputRotation(.noRotation, at: 0) case .All: self.filterView?.setInputRotation(.noRotation, at: 0) }

Same codes are work fine for Image Filter but getting issue in video filter.

I wasted my 3 day :( hope any one come ahead and give proper solution for this. Thanks You