BradLarson / GPUImage2

GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing.
BSD 3-Clause "New" or "Revised" License
4.87k stars 609 forks source link

Showing green lines at right and bottom of recorded video #224

Open aaasifrz9 opened 6 years ago

aaasifrz9 commented 6 years ago

I am using example from path: GPUImage2-master/examples/iOS/SimpleVideoRecorder GPUImage2

It records proper video and saving the file in camera roll without green lines using provided code in sample.

Issue 1: Now, I have changed some properties in ViewController.swift like

AVCaptureSessionPreset640x480 to AVCaptureSessionPresetHigh

Size(width:480, height:640) to Size(width:Float(UIScreen.main.bounds.size.width), height:Float(UIScreen.main.bounds.size.height))

and saved the video to camera roll. It saved properly. But the issue is, showing green lines at right and bottom of the recorded video and start playing with black shadow over video (in the first frame). Why video is showing green lines.

Issue 2: Chenged camera = try Camera(sessionPreset:AVCaptureSessionPreset640x480) to
camera = try Camera(sessionPreset:AVCaptureSessionPresetHigh, cameraDevice: nil, location: .frontFacing, captureAsYUV: true)

It inverts video camera to 180 degrees and also records video inverted.

Please help, I want to record video of device size.

Updated ViewController file: https://www.dropbox.com/s/ysadca77wxvw6wx/ViewController.swift?dl=0 Recorded video green lines URL: https://www.dropbox.com/s/g43ic3cxyl3h62f/test.mp4?dl=0 Inverted Recorded video URL: https://www.dropbox.com/s/2cu4me3zlqpj4ix/test%202.mp4?dl=0

EriFisher commented 6 years ago

The green lines sometimes happen if GPUImage doesn't like the video format in my experience, but this usually happens all over the screen instead of just on the right side. The likely reason is the width of the video is not what your phone is processing and it compensates by drawing a green line in that region instead.

Your code for the movie output is the problem. movieOutput = try MovieOutput(URL:fileURL, size:Size(width:Float(UIScreen.main.bounds.size.width), height:Float(UIScreen.main.bounds.size.height)), liveVideo:true) Try for instance what the actual camera size is instead of what the Iphone screen size (They are never the same except sometimes on iPads). The problem likely is that the Iphone screen size isn't a perfect fraction of the camera size. For most phones now high usually is 1080 x 1920 for portrait ... 1920 x 1080 for landscape.

movieOutput = try MovieOutput(URL:fileURL, size:Size(width:Float(1080), height:Float(1920)), liveVideo:true)

The video inverted is normal in GPUImage2. This can be fixed if you fool around with the orientation settings inside the actual framework. I normally stick to either portrait or landscape so it might be a good idea to check only one in the settings for the entire project. It's not very fun fixing it to what you need, but if you use the framework learn the file that says imageorientation. If you look at various pull requests people have proposed fixes.

Best of luck.

aaasifrz9 commented 6 years ago

Thanks a lot @SoundandStuff .