Open Scubaboy opened 8 months ago
Hi, I'm using FFMediaToolKit in a Unity 3D project to create videos of Unity's 3D scene. I'm capturing Unity's camera view as follows:
_screenShot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); _captureCamera.targetTexture = _renderTexture; RenderTexture.active = _renderTexture; _screenShot.ReadPixels(new Rect(0,0,Screen.width, Screen.height),0,0); _screenShot.Apply(); var pixelData = _screenShot.GetRawTextureData();
The above code provides a byte array of raw pixel data. When I take the byte array and try to construct an 'ImageData' object
ImageData.FromArray(pixelData , ImagePixelFormat.Rgb24, Screen.width, Screen.height);
I get the following exception:
Pixel buffer size doesn't match size required by this image format.
You use the following formula to calculate the expected stride:
4 * (((GetBitsPerPixel(format) * width) + 31) / 32);
However the byte array generated by Unity is
Screen.Width x Screen.height x 3
3 bytes per pixel corresponding to the 'TextureFormat.RGB24'
Is there any course of action I can take to resolve this difference?
Hi, I'm using FFMediaToolKit in a Unity 3D project to create videos of Unity's 3D scene. I'm capturing Unity's camera view as follows:
The above code provides a byte array of raw pixel data. When I take the byte array and try to construct an 'ImageData' object
I get the following exception:
You use the following formula to calculate the expected stride:
However the byte array generated by Unity is
3 bytes per pixel corresponding to the 'TextureFormat.RGB24'
Is there any course of action I can take to resolve this difference?