0

I want to convert YUV Packed (Or YUV Planner) in to Standard BMP file. in VC++2010,

  1. Through Command line and ffmapeg i am able to convert it

    (example:1)

    "ffmpeg -video_size 2448X2050 -pixel_format uyvy422 -i sample.yuv sample.bmp"
    

    (Example:2)

    "ffmpeg -video_size 2448X2050 -pixel_format yuvj420 -i sample.yuv sample.bmp"
    
  2. but i am looking way out that this operation to be performed with in my vc++2010 code (through ffmpeg if possible)

please suggest/recommend how do i proceed.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • Assuming the YUV buffer is in memory, you may use `_popen` and `fwrite` as in my [answer](https://stackoverflow.com/a/61148924/4926757). You don't need the OpenCV part, because you are dealing with raw frame format. Something like: `FILE *pipeout = _popen("ffmpeg -f rawvideo -video_size 2448X2050 -pixel_format uyvy422 -i pipe: sample.bmp", "wb");` and `fwrite(image_arr, 1, 2448*2050, pipeout);` – Rotem Jan 11 '22 at 16:20
  • In case the input and the output are both files, and you have to convert one file (or few files), you may look for ways for executing external executable using C++. – Rotem Jan 11 '22 at 16:23
  • thanking you for your time and response, i have follow your suggestion code works fine and won't give any error but not generate .bmp file. only difference is in fwrite , here in image_arr (image array), i write complete image row by row in a loop something like "fwrite(&ImageData[RowNo][0], sizeof(char), RowSize,pipeout)" or i should write complete image in one go ? – user3743908 Jan 19 '22 at 07:11
  • It depands on how the image is stored in memory. – Rotem Jan 19 '22 at 08:55
  • image data come in form of UDP packet of size 1464, further transfer to image file using fwrite function packet by packet, and thus create complete file. like "fwrite(&ImageData[RowNo][0], sizeof(char), RowSize,fp)" – user3743908 Jan 19 '22 at 11:34
  • I didn't ask how image data is received. – Rotem Jan 19 '22 at 12:30
  • I am not going to post an answer... You asked for suggest/recommend how to proceed. The comment is my suggestion. I recommend you to do some reading. Learn the options for storing image data in memory. Figure out how packed YUV is stored and how planar YUV is stored. Learn the differences between YUV422 and YUV420 (in your above example you used both). In case you still have issues, I suggest you to learn how to ask a good question, and post a minimal reproducible code sample (post a new question). – Rotem Jan 19 '22 at 12:49

1 Answers1

0

it start working by using following command : FILE *pipeout = ("ffmpeg -f rawvideo -video_size 2448x2050 -pixel_format uyvy422 - i "input packed yuv file path" "output bmp file path without any space", "wb"); here i noticed fwrite is not required, thanking you for your suggestion.