New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPUImageView renders video brighter than AVPlayer #1306

Closed
heiko-s opened this Issue Nov 19, 2013 · 9 comments

Comments

Projects
None yet
6 participants
@heiko-s

heiko-s commented Nov 19, 2013

I'm recording a short video sequence on an iPhone and save the video to the camera roll. That works perfectly fine using GPUImageVideoCamera or standard AVFoundation components either way. After that, the plan is to load up the video via GPUImageMovie (initWithMovieUrl:) and start the playback.

Interestingly, when I use AVPlayer it all looks good - it renders exactly as I see it in the camera roll. But using GPUImageMovie and GPUImageView displays the same video much brighter - almost like a Gamma-filter on top of it:
https://dl.dropboxusercontent.com/u/1879994/gpuimage-comparison.png
(difference between how the video looks in AVPlayer versus GPUImageView)

I don't use any filters at all, I plug the GPUImageMovie directly into the GPUImageView ([movie addTarget: view]). There's nothing else fancy going on.

Can anyone help me with this one?

@heiko-s

This comment has been minimized.

Show comment
Hide comment
@heiko-s

heiko-s Nov 27, 2013

To provide a little more information here: It doesn't matter whether I record the video beforehand or just pick a pre-recorded video from the camera roll. The result is always the same: The video displayed with GPUImageMovie is always brighter, probably related to different exposure / white balance settings.

heiko-s commented Nov 27, 2013

To provide a little more information here: It doesn't matter whether I record the video beforehand or just pick a pre-recorded video from the camera roll. The result is always the same: The video displayed with GPUImageMovie is always brighter, probably related to different exposure / white balance settings.

@BradLarson

This comment has been minimized.

Show comment
Hide comment
@BradLarson

BradLarson Nov 27, 2013

Owner

That's most likely due to a slight difference in the way that I convert YUV sources to RGB when loading from movies and video sources. Look at the matrix applied in the kGPUImageYUVVideoRangeConversionForLAFragmentShaderString and the like. I had been using Apple's standard YUV conversion, then a couple of people changed it, saying that it didn't match what it should be. Perhaps they were wrong, and the color matrix still needs to be adjusted here.

Owner

BradLarson commented Nov 27, 2013

That's most likely due to a slight difference in the way that I convert YUV sources to RGB when loading from movies and video sources. Look at the matrix applied in the kGPUImageYUVVideoRangeConversionForLAFragmentShaderString and the like. I had been using Apple's standard YUV conversion, then a couple of people changed it, saying that it didn't match what it should be. Perhaps they were wrong, and the color matrix still needs to be adjusted here.

@jackwu95

This comment has been minimized.

Show comment
Hide comment
@jackwu95

jackwu95 Feb 11, 2014

Hey Brad,

This seems like definitely the case, you should revert the YUV conversion back to before the fishy "Re-working GPUImageVideoCamera to use the YUV->RGB transform method s..." change, probably by just changing the matrices back.

I can submit a pull request for this if you want.

See another article on this here http://tuohuang.info/gpuimage_movie_writer_exposure_problem/#.Uvq0HEJdUeM

jackwu95 commented Feb 11, 2014

Hey Brad,

This seems like definitely the case, you should revert the YUV conversion back to before the fishy "Re-working GPUImageVideoCamera to use the YUV->RGB transform method s..." change, probably by just changing the matrices back.

I can submit a pull request for this if you want.

See another article on this here http://tuohuang.info/gpuimage_movie_writer_exposure_problem/#.Uvq0HEJdUeM

@BradLarson

This comment has been minimized.

Show comment
Hide comment
@BradLarson

BradLarson Feb 11, 2014

Owner

Yeah, I've had it on my list to change that back. I need to do that, but I'm in the middle of overhauling something else, and I wanted to finish that first. Been drawn away by work lately, so haven't been able to finish things as quickly as I would like.

Owner

BradLarson commented Feb 11, 2014

Yeah, I've had it on my list to change that back. I need to do that, but I'm in the middle of overhauling something else, and I wanted to finish that first. Been drawn away by work lately, so haven't been able to finish things as quickly as I would like.

@jackwu95

This comment has been minimized.

Show comment
Hide comment
@jackwu95

jackwu95 Feb 12, 2014

@BradLarson I submitted a tiny pull request here #1415.
I greatly appreciate the work that has gone into this library and I'll try contributing more as I familiarize more and more with it!

jackwu95 commented Feb 12, 2014

@BradLarson I submitted a tiny pull request here #1415.
I greatly appreciate the work that has gone into this library and I'll try contributing more as I familiarize more and more with it!

@tuo

This comment has been minimized.

Show comment
Hide comment
@tuo

tuo Feb 14, 2014

@jackwu95 I did compare it with Apple's GLCameraRipple sample code.

However still it needs one extra change :

make sure all CVOpenGLESTextureCacheCreateTextureFromImage in GPUImageVideoCamera.m and GPUImageMovie.m for luminance and chrominance use GL_RED_EXT rather than GL_LUMINANCE,GL_RG_EXT rather than GL_LUMINANCE_ALPHA.

I don't know why those two lines are got commented out, but I have tried that and found it works quite nice :)

tuo commented Feb 14, 2014

@jackwu95 I did compare it with Apple's GLCameraRipple sample code.

However still it needs one extra change :

make sure all CVOpenGLESTextureCacheCreateTextureFromImage in GPUImageVideoCamera.m and GPUImageMovie.m for luminance and chrominance use GL_RED_EXT rather than GL_LUMINANCE,GL_RG_EXT rather than GL_LUMINANCE_ALPHA.

I don't know why those two lines are got commented out, but I have tried that and found it works quite nice :)

@zmzhuai

This comment has been minimized.

Show comment
Hide comment
@zmzhuai

zmzhuai Feb 17, 2014

Contributor

@tuo I think u missed mention one change, I changed GL_LUMINANCE to GL_RED_EXT, It will get the red image. So I find out, It's need change all kGPUImageYUVVideoRangeConversionForLAFragmentShaderString to kGPUImageYUVVideoRangeConversionForRGFragmentShaderString. and use conversion matrix in GLCameraRipple sample code. It's works perfect.

Contributor

zmzhuai commented Feb 17, 2014

@tuo I think u missed mention one change, I changed GL_LUMINANCE to GL_RED_EXT, It will get the red image. So I find out, It's need change all kGPUImageYUVVideoRangeConversionForLAFragmentShaderString to kGPUImageYUVVideoRangeConversionForRGFragmentShaderString. and use conversion matrix in GLCameraRipple sample code. It's works perfect.

@zmzhuai

This comment has been minimized.

Show comment
Hide comment
@zmzhuai

zmzhuai Feb 18, 2014

Contributor

@tuo I test it, and find out use GL_LUMINANCE or GL_RED_EXT is just like same. problem is the conversion matrix in GPUImage is wrong. I use matrix in GLCameraRipple, and test GL_LUMINANCE and GL_RED_EXT, is the same.GL_RED_EXT need A5 device support.

Contributor

zmzhuai commented Feb 18, 2014

@tuo I test it, and find out use GL_LUMINANCE or GL_RED_EXT is just like same. problem is the conversion matrix in GPUImage is wrong. I use matrix in GLCameraRipple, and test GL_LUMINANCE and GL_RED_EXT, is the same.GL_RED_EXT need A5 device support.

@BradLarson BradLarson closed this May 26, 2014

@huize

This comment has been minimized.

Show comment
Hide comment
@huize

huize Dec 22, 2014

when the source video color type is kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange ,the probleam still exit,please look #1869

huize commented Dec 22, 2014

when the source video color type is kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange ,the probleam still exit,please look #1869

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment