[Ffmpeg-devel] YUV codec with x264 + BUG

Christian Bienia cbienia
Tue Oct 10 03:22:14 CEST 2006


Hello Dan,

thanks for your reply. I could solve the problem after a more thorough
source code review. x264 only accepts YUV 4:2:0 data with 12bpp, which
is not the pixel format which you get if you simply use ffmpeg as
follows:


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


Because the resulting file is twice as big, I assume ffmpeg uses one of
the 24bpp formats by default. The key here is to use the option -pix_fmt
as follows:


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


If the yuv file is created with the above command, everything works as
it should. However, -pix_fmt is not documented. There is also no list of
pixel formats which can be specified, and using a pixel format name
which is not defined results in a segfault, for example:


ffmpeg -f image2 -i %03d.png -pix_fmt yuv420 rawvideo.y4m
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2004 Fabrice Bellard
  configuration:  --enable-pthreads --enable-a52 --enable-gpl
--disable-ffserver --disable-ffplay
  libavutil version: 49.0.0
  libavcodec version: 51.14.0
  libavformat version: 50.5.0
  built on Sep 19 2006 16:42:54, gcc: 3.4.3 20050227 (Red Hat
3.4.3-22.1)
Input #0, image2, from '%03d.png':
  Duration: 00:00:00.6, start: 0.000000, bitrate: N/A
  Stream #0.0: Video: png, rgb24, 640x360, 25.00 fps(r)
Segmentation fault


- Chris



On Mon, 2006-10-09 at 21:46, Dan Maas wrote:
> Is one of your programs using 4:4:4 sampling and another using 4:2:2
> sampling? Most YUV formats are 4:2:2 (i.e. the two chroma channels are
> half the resolution of the luma channel horizontally)
> 
> I don't get the factor of 3/2. The size of an 8-bit 4:2:2 buffer is
> width*height*2 bytes.
> 
> Regards,
> Dan
> 
> * Christian Bienia (cbienia at cs.princeton.edu) wrote:
> > Hi,
> > 
> > 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 
> > documentation:
> > 
> > 
> > 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 
> > muxers.c:
> > 
> > 
> > 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 
> > pixel?
> > 
> > Thanks a lot for the help in advance.
> > 
> > - Chris
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel at mplayerhq.hu
> > http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel
> > 
> > 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at mplayerhq.hu
> http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel





More information about the ffmpeg-devel mailing list