[FFmpeg-user] Decode to BGR24 avi

Timo Stjernberg timo.infradex at gmail.com
Tue Jan 29 12:06:32 CET 2013


Hello.

I am returning this issue back via the actual mailing list, since posting
via nabble.com doesn't seem to work right. Refer to
http://ffmpeg-users.933282.n4.nabble.com/Decode-to-BGR24-raw-AVI-td4653855.htmlfor
the original thread.

There seems to be a disagreement between FFmpeg and VirtualDub of what
uncompressed bgr24 raw avi really is. I can tell this already by looking at
file sizes that they produce from the same video but PSNR & other metrics
tell me they're definitely not the same video.

I have done extensive testing on different videos with ffmpeg and so I
decided to set this test up for you guys to figure out what is going south
on bgr24 raw avi's.

All example video files are accessible at http://videotimo.fi/ffmpeg/

TEST PHASE 1:
We start with a raw original avi that has been built from PNG frames with
VirtualDub (sintel_raw_original.avi). We make a rawvideo -pix_fmt bgr24
copy of it with ffmpeg to find out that even when there should be no
difference between input and output, the files are not the same in size.
(sintel_ffmpeg_raw2raw.avi)

Console output:

ffmpeg -i G:\Testivideot\sintel_raw_original.avi -vcodec rawvideo -pix_fmt
bgr24 sintel_ffmpeg_raw2raw.avi:

ffmpeg version N-47062-g26c531c Copyright (c) 2000-2012 the FFmpeg
developers
  built on Nov 25 2012 12:21:26 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads
--enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r
--enable-libass -
-enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype
--enab
le-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg
--enable-libo
pus --enable-librtmp --enable-libschroedinger --enable-libspeex
--enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid
--ena
ble-zlib
  libavutil      52.  9.100 / 52.  9.100
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 37.100 / 54. 37.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.102 /  3. 23.102
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
Input #0, avi, from 'G:\Testivideot\sintel_raw_original.avi':
  Duration: 00:00:01.21, start: 0.000000, bitrate: 234514 kb/s
    Stream #0:0: Video: rawvideo, bgr24, 848x480, 24 tbr, 24 tbn, 24 tbc
Output #0, avi, to 'd:\sintel_ffmpeg_raw2raw.avi':
  Metadata:
    ISFT            : Lavf54.37.100
    Stream #0:0: Video: rawvideo, bgr24, 848x480, q=2-31, 200 kb/s, 24 tbn,
24 t
bc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> rawvideo)
Press [q] to stop, [?] for help
frame=   21 fps=0.0 q=0.0 size=   25048kB time=00:00:00.87
bitrate=234508.5kbits
frame=   29 fps=0.0 q=0.0 Lsize=   34589kB time=00:00:01.20
bitrate=234497.3kbit
s/s
video:34582kB audio:0kB subtitle:0 global headers:0kB muxing overhead
0.018011%
----------------------------------------------------------------------------------
TEST PHASE 2:

We encode the raw original to mpeg2 (sintel_ffmpeg_raw2mpeg2.avi). The
encode goes smoothly.

Console output:

ffmpeg -i sintel_raw_original.avi -vcodec mpeg2video -b:v 2000k
sintel_ffmpeg_raw2mpeg2.avi:

ffmpeg version N-47062-g26c531c Copyright (c) 2000-2012 the FFmpeg
developers
  built on Nov 25 2012 12:21:26 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads
--enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r
--enable-libass -
-enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype
--enab
le-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg
--enable-libo
pus --enable-librtmp --enable-libschroedinger --enable-libspeex
--enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid
--ena
ble-zlib
  libavutil      52.  9.100 / 52.  9.100
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 37.100 / 54. 37.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.102 /  3. 23.102
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
Input #0, avi, from 'G:\Testivideot\sintel_raw_original.avi':
  Duration: 00:00:01.21, start: 0.000000, bitrate: 234514 kb/s
    Stream #0:0: Video: rawvideo, bgr24, 848x480, 24 tbr, 24 tbn, 24 tbc
Output #0, avi, to 'd:\sintel_ffmpeg_raw2mpeg2.avi':
  Metadata:
    ISFT            : Lavf54.37.100
    Stream #0:0: Video: mpeg2video (mpg2 / 0x3267706D), yuv420p, 848x480,
q=2-31
, 2000 kb/s, 24 tbn, 24 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mpeg2video)
Press [q] to stop, [?] for help
frame=   19 fps=0.0 q=4.0 size=     302kB time=00:00:00.70
bitrate=3494.3kbits/s
frame=   29 fps=0.0 q=3.5 Lsize=     408kB time=00:00:01.16
bitrate=2865.0kbits/
s
video:402kB audio:0kB subtitle:0 global headers:0kB muxing overhead
1.554130%
------------------------------------------------------------------------------
TEST PHASE 3:

We decode the mpeg2 video back to bgr24 raw avi
(sintel_ffmpeg_mpeg2toRAW.avi). The result is not at all what I would
expect. The decoded video has one frame more than the original. Therefore
if I compare the original and the decoded video for PSNR or MAE, the
calculations don't match at all. Only if I strip the first frame from the
decoded avi, the calculations seem valid.

Console output:
ffmpeg -i D:\sintel_ffmpeg_raw2mpeg2.avi -vcodec rawvideo -pix_fmt bgr24
d:\sintel_ffmpeg_mpeg2toRAW.avi

ffmpeg version N-47062-g26c531c Copyright (c) 2000-2012 the FFmpeg
developers
  built on Nov 25 2012 12:21:26 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-pthreads
--enable-runt
ime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r
--enable-libass -
-enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libfreetype
--enab
le-libgsm --enable-libmp3lame --enable-libnut --enable-libopenjpeg
--enable-libo
pus --enable-librtmp --enable-libschroedinger --enable-libspeex
--enable-libtheo
ra --enable-libutvideo --enable-libvo-aacenc --enable-libvo-amrwbenc
--enable-li
bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid
--ena
ble-zlib
  libavutil      52.  9.100 / 52.  9.100
  libavcodec     54. 77.100 / 54. 77.100
  libavformat    54. 37.100 / 54. 37.100
  libavdevice    54.  3.100 / 54.  3.100
  libavfilter     3. 23.102 /  3. 23.102
  libswscale      2.  1.102 /  2.  1.102
  libswresample   0. 17.101 /  0. 17.101
  libpostproc    52.  2.100 / 52.  2.100
Input #0, avi, from 'D:\sintel_ffmpeg_raw2mpeg2.avi':
  Metadata:
    encoder         : Lavf54.37.100
  Duration: 00:00:01.21, start: 0.000000, bitrate: 2766 kb/s
    Stream #0:0: Video: mpeg2video (Main) (mpg2 / 0x3267706D), yuv420p,
848x480
[SAR 1:1 DAR 53:30], 24 fps, 24 tbr, 24 tbn, 48 tbc
Output #0, avi, to 'd:\sintel_ffmpeg_mpeg2toRAW.avi':
  Metadata:
    ISFT            : Lavf54.37.100
    Stream #0:0: Video: rawvideo, bgr24, 848x480 [SAR 1:1 DAR 53:30],
q=2-31, 20
0 kb/s, 24 tbn, 24 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video -> rawvideo)
Press [q] to stop, [?] for help
frame=   29 fps=0.0 q=0.0 Lsize=   34589kB time=00:00:01.25
bitrate=226681.3kbit
s/s
video:34582kB audio:0kB subtitle:0 global headers:0kB muxing overhead
0.018293%
---------------------------------------------------------------------------------

This extraneous frame does seem to appear at least with VC-1 and mpeg2
encode/decode process. Still, something is done very differently on all
bgr24 raw avi decodes because I still have to run all the raw avi decodes
through VirtualDub after ffmpeg before feeding the test videos to the PSNR
calculator.

Additionally, Microsoft Expression Encoder 4 doesn't seem to understand the
raw avi produced by ffmpeg at all.

Anybody had any similar incidents? Anybody that can clarify any of this?
What am I doing wrong?


More information about the ffmpeg-user mailing list