Decoding video pixel data in C++ using FFmpeg (Part 2)

preview_player
Показать описание


This part of the livestream builds on what we've done before. I successfully decode a video frame, but the pixel data is stored in YUV as opposed to RGB. So in this short tutorial I change the color format using libswscale to RGB.

Рекомендации по теме
Комментарии
Автор

Such an awesome tutorial, along with the previous video. So detailed yet so concise. Absolute legend.

zacharynicoll
Автор

This tutorial is awesome! I wish I had found this video before. Doing this without context is like falling down a staircase in the dark.

sephjfox
Автор

Awesome work dude. wish you could do more ffmpeg tutorials!

ytbTheogr
Автор

Great video overall! Your simple explanation of the human visual system is generally correct when you say we see luminance better than color. However, more specifically, we are more sensitive to luminance *spatially*.


It’s unfortunate the term YUV is used in FFMPEG as it is an outdated term from the analog days where Y’CbCr is digital.

adamburke
Автор

13:11 why do we need 4 buffers, while we dont use 3 of them? I have not found proper docs/examples yet, but i got rid of them and there is no difference between 1, 2, 7, 12... buffers

babymetalsheets
Автор

You would be much better off uploading the YUV frames to the GPU and then writing a shader to convert to RGB for final display.Not only do you not need to use loads of CPU resources to handle the conversion, but also you save PCIe bandwidth, not to mention the fact that GPUs handle upload of 2BPP formats a lot better than 3BPP pixel formats.

thisiscentralcontrol
Автор

@Bartholomew
How do i save these
*width_out = av_frame->width;
*height_out = av_frame->height;
*data_out = data;
in png file.

I tried but the image is full black??
FILE *pFile;
pFile = fopen("frame.png", "wb");

if (!pFile) {
ALOG("Couldn't get pFile\n");
return false;
}
fprintf(pFile, "P6\n%d %d\n255\n", av_frame->width, av_frame->height);
for (y = 0; y < av_frame->height; y++)
fwrite(data, 1, av_frame->width * 3, pFile);
fclose(pFile);

peacehappinessmoment
Автор

hey thanks for the tutorial. i've been getting problems decode h264 to raw rgb without unwanted color or brightness shifting, do you know how to do it?

amadeokusch
Автор

Can you please decode video an audio both in c++

shubhampancholi