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?
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:0
format 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.