user3743908
user3743908

Reputation: 59

How to convert YUV422 image to JPEG using ffmpeg's libraries?

I'm trying to convert a YUV422 image (YUV422_8_UYVY, unsigned ,unpacked, 16bpp) in to jpeg using ffmpeg's ,this is Code which I am following

Image size: 2448x2050 Original YUV Image: not able to upload as the format is YUV

(Original Image Decodec by ffmpeg command prompt) Image:This is original Image

Image size: 2448x2050 reconstruct Image:Reconstruct Image through above Code

so the reconstruct image is not as the original image

my format is UYVY whereas supported format is AV_PIX_FMT_YUVJ420P

so what should be the correct format for UYVY input image...?

pCodecCtx->pix_fmt=AV_PIX_FMT_?????

if i use pCodecCtx->pix_fmt=AV_PIX_FMT_UYVY422; i got an arrer saying

[mjpeg @ 00c0b2a0] specified pixel format uyvy422 is invalid or not supported

Upvotes: 0

Views: 1890

Answers (1)

Ronald S. Bultje
Ronald S. Bultje

Reputation: 11174

You say the image format is "unpacked" (??), but at the same time you call it YUV422_8_UYVY, which suggests it's packed (i.e. not planar). The output you're getting suggests that it's packed.

FFmpeg's image encoders, in general, do not support packed input. You first need to make it planar. You have two options:

  • convert it to planar YUV-4:2:2 (AV_PIX_FMT_YUVJ422P) and input that into the encoder;
  • convert it to planar YUV-4:2:0 (AV_PIX_FMT_YUVJ420P) and input that into the encoder.

The first will preserve chroma subsampling (better quality), but the second will have better downstream support (in other applications, to decode the image). To convert the image, you use libswscale. The output image from that conversion can be input into the FFmpeg encoder.

Upvotes: 1

Related Questions