[FFmpeg-user] ffmpeg scaling example.

Vittalprasad vittalprasad.br at gmail.com
Thu Mar 1 15:42:23 EET 2018


Hi All,
Scaling_video.c example file modified to convert 1080p_YUV420 file to
240pYUV420. After conversion  Luma content is fine, but chroma(color)
contents are mismatching with original file.
I attached modified code, please direct me to get correct chroma contents
also.
 long int resol = (src_w * src_h *3)>>1;
        int noframes = opusFileSize/resol;
        printf("No of frames%d\n", noframes);
        //
        unsigned char* pYUV = NULL;
        pYUV = (unsigned char *) malloc( resol);
        if (pYUV == NULL)
                exit(0);

        src_data[0] = pYUV;
        src_data[1] =  pYUV + (src_w *src_h);
        src_data[2] =  pYUV + (resol>>2);
        src_linesize[0]= src_w;
        src_linesize[1]= src_linesize[2]= src_w >>1;
        for (i = 0; i < noframes; i++) {
                /* generate synthetic video */
                //fill_yuv_image(src_data, src_linesize, src_w, src_h, i);
                memset( pYUV, 0, resol );
                fread(pYUV, 1, resol, fp);
                /* convert to destination format */
                sws_scale(sws_ctx, (const uint8_t * const*)src_data,
                                src_linesize, 0, src_h, dst_data,
dst_linesize);
                /* write scaled image to file */
                fwrite(dst_data[0], 1, dst_bufsize, dst_file);
        }


-- 
Thanks & Regards
Vittal Prasad B R


More information about the ffmpeg-user mailing list