-3

I have a .yuv file and want to read it using C++. The issue is that I don't know it's resolution. So, is there any means to derive the resolution from the yuv file ?

Also, I don't know the number of frames. Hence, I can't use ftell() and divide it by the total frames.

darshshah
  • 35
  • 4
  • What software has the yuv file been created with? What have you tried so far? What information do you have about the file format? – Herr von Wurst Oct 03 '12 at 10:41

1 Answers1

6

As far as I know there's no .yuv file format. Some programs use that extension to store raw data, but it's not a format. Therefore there's no way to use the file unless you already know the metadata.

And you need to know in advance if the chroma samples are interleaved with the luminance ones or stored separately and if there's any bit padding and/or any row padding, just to be able to read the data from the file.

Then you also need to know in advance the frame resolution, the chroma subsampling and the color space in order to be able to correctly process that data.

Analog File
  • 5,149
  • 18
  • 23
  • i meant yuv images to be specific – darshshah Oct 03 '12 at 14:20
  • The difference is minimal. With images you may check the file size and "guess" some of the metadata if you know some other, but in general you still need to know pretty much everything in advance. – Analog File Oct 03 '12 at 18:18
  • @darshshah re: "yuv images": Georg and AnalogFile are correct, there is no "standard" YUV image file format. But many "standard" image formats are capable of holding a YUV image. they have a file header that gives you all the required information. Without that file header, you must either guess, or experiment. #1 see which YUV formats might possibly add up to that image size. #2 Then display them all to see which is correct. YUV 4:2:0 needs W*H*3/2; YUV 4:2:2 needs W*H*2; etc. – Jesse Chisholm Sep 10 '14 at 21:40