0

I have an image file myImage.yuv with UV planes interleaved and I want to convert it into png.

I'm using:

ffmpeg -pixel_format yuv420p -video_size 1944x1204 -i myImage.yuv output.png

This would be OK if the image wasn't interleaved, how can I specify this to ffmpeg?

Ivan
  • 1,352
  • 2
  • 13
  • 31
  • UV planes interleaved? Do you mean [NV12](https://i.stack.imgur.com/XboNY.png) pixel format? `ffmpeg -pixel_format nv12 -video_size 1944x1204 -i myImage.yuv output.png` – Rotem Apr 08 '22 at 08:28
  • @Rotem exactly, this solved it. Maybe you can post it like an answer? – Ivan Apr 08 '22 at 12:43

2 Answers2

1

UV planes interleaved applies NV12 pixels format.

We may use the following command for converting raw NV12 file to PNG image:

ffmpeg -pixel_format nv12 -video_size 1944x1204 -i myImage.yuv output.png

NV12 format is YUV420 pixel format ordered in semi-planar format, where the Y channel is in one plane, and the interleaved UV elements are in a second plane.

The following diagram demonstrates the NV12 format:
enter image description here

Note: I created the diagram back in 2016, for the following post (the post has few more details about the NV12 format).

Rotem
  • 30,366
  • 4
  • 32
  • 65
0

Try swapuv filter

ffmpeg -pixel_format yuv420p -video_size 1944x1204 -i myImage.yuv \
       -vf swapuv output.png
kesh
  • 4,515
  • 2
  • 12
  • 20
  • This changes the output, but not in the right way. My image is organized as First all `Y` and then `U`and `V` values "interleaved" . Not sure This was clear in my question – Ivan Apr 07 '22 at 14:33
  • Doh, sorry, I completely misunderstood your question. See if `swapuv` does the job – kesh Apr 07 '22 at 14:40