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.h... 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?
On 1/29/13, Timo Stjernberg <timo.infradex@gmail.com> wrote:
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.h... 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.
If you open bug report and upload working raw avi (with first say 10 frames) and provide link to uploaded contet in same bug report than someone could take look at that bug report and at least provide some kind of workaround.
Anybody had any similar incidents? Anybody that can clarify any of this? What am I doing wrong? _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Timo Stjernberg <timo.infradex <at> gmail.com> writes:
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.
You can use -vsync 0 to stop FFmpeg from duplicating the first frame. Carl Eugen
Timo Stjernberg <timo.infradex <at> gmail.com> writes:
Additionally, Microsoft Expression Encoder 4 doesn't seem to understand the raw avi produced by ffmpeg at all.
I tested sintel_ffmpeg_raw2raw.avi with WMP and it plays fine. (WMP is considered here the relevant testing application for avi.) Carl Eugen
Carl Eugen Hoyos wrote
Timo Stjernberg <timo.infradex <at> gmail.com> writes:
Additionally, Microsoft Expression Encoder 4 doesn't seem to understand the raw avi produced by ffmpeg at all.
I tested sintel_ffmpeg_raw2raw.avi with WMP and it plays fine. (WMP is considered here the relevant testing application for avi.)
Carl Eugen
_______________________________________________ ffmpeg-user mailing list
ffmpeg-user@
This is a rather old discussion, but I've found the explanation. Bad PSNR values were produced because the avi content was upside down. That was of course not apparent by looking at the clips on WMP or the likes. They know it is AVI that should be flipped because of some AVI header directive. VirtualDub produces a different version on AVI. Both (FFmpeg & VirtualDub) do work on WMP. -- View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Decode-to-BGR24-avi-tp4656854p46697... Sent from the FFmpeg-users mailing list archive at Nabble.com.
Timo S <timo.infradex <at> gmail.com> writes:
This is a rather old discussion, but I've found the explanation. Bad PSNR values were produced because the avi content was upside down.
In your original email, you wrote that PSNR was ok if the first (duplicated) frame was removed iirc.
That was of course not apparent by looking at the clips on WMP or the likes.
They know it is AVI that should be flipped because of some AVI header directive. VirtualDub produces a different version on AVI.
Could you elaborate on "different version"? Carl Eugen
Carl Eugen Hoyos wrote
In your original email, you wrote that PSNR was ok if the first (duplicated) frame was removed iirc.
Actually, this got confused with another problem with encoding to mpeg2 which I already figured out. The real problem was not here. Sorry. :) The real issue with avi decoding was found out by dissecting the avi headers and comparing them side by side with the one VirtualDub generated. Here is part of the header that VirtualDub generated: offset=0xAC header_size: 40 image_width: 512 image_height: 512 number_of_planes: 1 bits_per_pixel: 24 compression_type: 0 And here the same part that FFmpeg generated: offset=0xAC header_size: 40 image_width: 512 image_height: -512 number_of_planes: 1 bits_per_pixel: 24 compression_type: 0 The crucial difference is a negative image_height, indicating that the image content is upside down. The PSNR calculator did not notice this and so, because the original avi had a positive height and the comparison avi had a negative height, bad PSNRs would result. Carl Eugen Hoyos wrote
Could you elaborate on "different version"?
I hope the above was sufficient. :) "Different version" means that the two AVIs that were compared with the PSNR calculator had their contents in different order. Both were BGR24 uncompressed AVIs. Frame accurately the same, just their byte content was not in the same order. Bottom line, the fault was in the PSNR calculator that should have alerted me. -- View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Decode-to-BGR24-avi-tp4656854p46697... Sent from the FFmpeg-users mailing list archive at Nabble.com.
Carl Eugen Hoyos wrote
I believe that this is simply wrong, raw BGR24 needs a negative value here iirc.
That's right. It is however the way VirtualDub 1.9.11 works with uncompressed AVI. Never mind though, I've stopped using VirtualDub altogether, since all my testing is now performed with FFmpeg. -- View this message in context: http://ffmpeg-users.933282.n4.nabble.com/Decode-to-BGR24-avi-tp4656854p46697... Sent from the FFmpeg-users mailing list archive at Nabble.com.
participants (4)
-
Carl Eugen Hoyos -
Paul B Mahol -
Timo S -
Timo Stjernberg