Flutter - Convert YUV to RGB

285 views Asked by At

New to flutter so hopefully you can help.

I've got a directory full of .yuv files (created from startImageStream() with the camera package - ImageFormatGroup.yuv420).

I'd like to convert these files to jpg.

Is there a native way to do this? So, read the .yuv file, convert to rgb, save as .jpg I'd think.

I am not doing this with startImageStream() to process each file when it's created, but doing separately.

I tried using methods such as readAsBytesSync and fromBytes but not making much progress.

final filePath = '/path/to/yuv_file.yuv';
  final yuvData = File(filePath).readAsBytesSync();
  final rgbData = img.Image.fromBytes(int 1080, int 840);
  File('output.jpg').writeAsBytesSync(img.encodeJpeg(rgbData));
0

There are 0 answers