[Ffmpeg-devel] YUV codec with x264

Christian Bienia cbienia
Mon Oct 9 19:42:13 CEST 2006


I'm trying to put together a few uncompressed YUV videos for benchmarking 
purposes. I'd appreciate if somebody could help me with a problem I have: For 
some reason the videos I get from ffmpeg are a factor 2 bigger than what x264 
expects. I generated the YUV video from PNG files as described in the 

ffmpeg -f image2 -i %03d.png rawvideo.yuv

Some math revealed that ffmpeg uses 3 bytes per pixel. However, x264 expects 
only half as many, as can be seen in the function get_frame_total_yuv in 

int get_frame_total_yuv( hnd_t handle )
    yuv_input_t *h = handle;
    int i_frame_total = 0;

    if( !fseek( h->fh, 0, SEEK_END ) )
        uint64_t i_size = ftell( h->fh );
        fseek( h->fh, 0, SEEK_SET );
        i_frame_total = (int)(i_size / ( h->width * h->height * 3 / 2 ));

    return i_frame_total;

That results in twice as many frames being detected as actually exist in the 
file. Could somebody point me to my mistake? I assume I didn't use the right 
options with ffmpeg, so is it possible to tell it to use only 3/2 bytes per 

Thanks a lot for the help in advance.

- Chris

More information about the ffmpeg-devel mailing list