[FFmpeg-user] Decode H264 and save to yuv file

edward20 edward.chopuryan at gmail.com
Tue Jul 30 10:25:51 CEST 2013


Anyone? Please I just need part of C code which
explains how to write decoded YUV data to file.
Is there any example of it?

Here is what I have tried so far



void write_frame_to_file(AVFrame* frame, int width, int height, int iframe)
{
        FILE* outfile;
        char filename[32];
        int y;

        // Open file
        sprintf(filename, "frame%d.yuv", iframe);
        outfile = fopen(filename, "wb");
        if (outfile == NULL) {
                return;
        }

        // Write pixel data
        for (y = 0; y < height; ++y) {
                fwrite(frame->data[0]+y*frame->linesize[0], 1, width*3,
outfile);
        }

        // Close file
        fclose(outfile);
        printf("file is closed\n");
}




--
View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Decode-H264-and-save-to-yuv-file-tp4660204p4660315.html
Sent from the FFmpeg-users mailing list archive at Nabble.com.


More information about the ffmpeg-user mailing list