[FFmpeg-devel] output rawvideo 32bit

Rik Maes rik.maes54 at gmail.com
Fri Dec 16 09:05:30 CET 2011


Hi folks,

my (and obviously not only my) problem :
 " ffmpeg.exe -i abcd.xxx -vcodec rawvideo -pix_fmt rgb32 -y out.avi  "
doesn't work : the out.avi is not a valid avi file.

my solution :
in file " riff.c " (in libavformat folder) :

"
/* BITMAPINFOHEADER header */
void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const
AVCodecTag *tags, int for_asf)
{
    avio_wl32(pb, 40 + enc->extradata_size); /* size */
    avio_wl32(pb, enc->width);
    //We always store RGB TopDown
    avio_wl32(pb, enc->codec_tag ? enc->height : -enc->height);
    avio_wl16(pb, 1); /* planes */
    avio_wl16(pb, enc->bits_per_coded_sample ? enc->bits_per_coded_sample :
24); /* depth */
    /* compression type */
    avio_wl32(pb, enc->codec_tag);
    avio_wl32(pb, enc->width * enc->height * 3);
<==================   (line 520 in this file)
    ...
"
should be : " ... enc->width * enc->height * 4); " for all rawvideo 32bit
flavors.

So replacing line 520 with :
   "  avio_wl32(pb, enc->width * enc->height * (enc->bits_per_coded_sample
>>3));  "
does the job.

I hope this idea will help to improve your fantastic project.

Rik Maes
Belgium


More information about the ffmpeg-devel mailing list