0

I have a file, I want to know whether it is NV12 format, how to judge a file is a nv12 format file? Is there any tool or test code?

Rotem
  • 30,366
  • 4
  • 32
  • 65
Lyric
  • 15
  • 1
  • 5

1 Answers1

1

One way is to use mplayer The following should work (here I'm assuming a CIF-size, i.e 352, 288)

$ mplayer -demuxer rawvideo -rawvideo w=352:h=288:format=nv12 file.yuv

To convert from. let's say 4:2:0 plane separated (a.k.a YV12, which pretty much is the standard) you can use ffmpeg:

$ ffmpeg -pix_fmt yuv420p -s 352x288 -i foreman_352x288.yuv -pix_fmt nv12 foreman_nv_12.yuv

yuv is a raw-data format without any headers so there's nothing you really can do than to try viewing it using different format until you manage to find a match.

Some basic consistency checks though are that NV12 is a 4:2:0format meaning that the chroma-planes are subsampled a factor 2 in both width and height and this gives a total byte count for one frame:

width * height * 3 / 2

this you can check against the total number of bytes for the file.

Fredrik Pihl
  • 44,604
  • 7
  • 83
  • 130
  • Hi, been trying to use this conversion, but I can't play the nv12 with the player. on converting with ffmpeg to other format it works OK. – ransh Nov 16 '15 at 14:16
  • which player are you referring to? Using ffmpeg, this should work `ffplay -s 352x288 -pix_fmt nv12 file.yuv` – Fredrik Pihl Nov 17 '15 at 13:48
  • thanks. I've must had an issue with buggy old version ffmpeg. I did the conversion and played it eventually – ransh Nov 17 '15 at 20:36
  • 7yuv is useful for nv12 (and other) conversions – ransh Nov 18 '15 at 08:09
  • or you can use my excellent python tool to do format conversion :-) https://github.com/figgis/yuv-tools – Fredrik Pihl Nov 19 '15 at 08:21