bugGNU Octave - Bugs: bug #64452, [octave forge] (video) BIST in...

 
 

bug #64452: [octave forge] (video) BIST in VideoWriter.m fails on ppc64el

Submitter:  Rafael Laboissière <rlaboiss>
Submitted:  Thu 20 Jul 2023 02:50:16 PM UTC
   
 
Category:  Octave Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  None Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * other Release: 
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 29 Apr 2025 05:27:11 AM UTC, comment #17: 

comment #15:

> Can you please file a bugreport for ffmpeg on ppc64el and add a link here?


I tried to create an account on the bug tracking system for FFmpeg, but was not successful.

For now, I have filed a bug report against the Debian package ffmpeg, in the hope that this will reach the upstream authors.

Rafael Laboissière <rlaboiss>
Mon 21 Apr 2025 07:45:32 AM UTC, comment #16: 

comment #15:

> Rafael, thank you very much for testing.
> Can you please file a bugreport for ffmpeg on ppc64el and add a link here?

Sure. Just for the record, I am attaching here the resulting video file with the artifacts (only the first 2 seconds).

(file #57152)

Rafael Laboissière <rlaboiss>
Sun 20 Apr 2025 07:37:49 PM UTC, comment #15: 

Rafael, thank you very much for testing.
Can you please file a bugreport for ffmpeg on ppc64el and add a link here?

Thank you, Andy

Andreas Weber <andy1978>
Group Member
Sun 20 Apr 2025 04:31:43 PM UTC, comment #14: 


comment #13:

> @rlaboiss: Do you have access to a real ppc64el machine or are you emulating one?


I built the package on a Debian porterbox:


$ ssh platti.debian.org
(sid_ppc64el-dchroot)rafael@platti:~$ uname -a
Linux platti 6.1.0-33-powerpc64le #1 SMP Debian 6.1.133-1 (2025-04-10) ppc64le GNU/Linux


> What happens if you recode a "real" (not artificial= video like
> pkg load video
> r = VideoReader("https://raw.githubusercontent.com/opencv/opencv/master/samples/data/vtest.avi")
> fn = "out_h264.mkv";
> w = VideoWriter (fn, "h264")
> while (r.hasFrame())
>   img = readFrame (r);
>   writeVideo (w, img);
> endwhile
> close (w)
> close (r)
>
> Do you see artifacts in the generated video?


Yes.

> If yes, do you the same when invoking ffmpeg yourself to convert vtest.avi to MAtroska+H264?


I run the following in the ppc64el system:


wget https://raw.githubusercontent.com/opencv/opencv/master/samples/data/vtest.avi
ffmpeg -i vtest.avi -vcodec libx264 out_h264-ffmpeg.mkv


The resulting file has the same artifacts as the one produced in Octave.

After all, the problem may come from a bug in the implementation of FFmpeg on ppc64el.

Rafael Laboissière <rlaboiss>
Sun 20 Apr 2025 09:30:22 AM UTC, comment #13: 

@rlaboiss: Do you have access to a real ppc64el machine or are you emulating one?

I don't know how I could debug this without beeing able to reproduce it.

What happens if you recode a "real" (not artificial= video like

pkg load video
r = VideoReader("https://raw.githubusercontent.com/opencv/opencv/master/samples/data/vtest.avi")
fn = "out_h264.mkv";
w = VideoWriter (fn, "h264")
while (r.hasFrame())
  img = readFrame (r);
  writeVideo (w, img);
endwhile
close (w)
close (r)


Do you see artifacts in the generated video? If yes, do you the same when invoking ffmpeg yourself to convert vtest.avi to MAtroska+H264?

Thank you for your help,
-- Andy

Andreas Weber <andy1978>
Group Member
Thu 17 Apr 2025 12:59:40 PM UTC, comment #12: 

I tried to build the package on a Debian ppc64el system and got the same errors as reported in my previous message. I am attaching here the resulting files from the failed tests.


$ ls -l oct-*
-rw-r--r--   1 rafael  rafael       29713 Apr 17 14:46  oct-yifWhv_rainbow_h264.mp4
-rw-r--r--   1 rafael  rafael       29640 Apr 17 14:47  oct-YQdbNJ_rainbow_default.mkv


As well as being the wrong size, they do not look smooth.

(file #57145, file #57146)

Rafael Laboissière <rlaboiss>
Thu 17 Apr 2025 12:49:59 PM UTC, comment #11: 

It is still failing for version 2.1.3 on Debian ppc64el:


***** test
 # mp4 + default codec (= avc1)
 fn = [tempname() "_rainbow_h264.mp4"];
 # median(rel_err) = 0.71% on Debian GNU/Linux 12 on AMD Ryzen 7 5700X
 # but 14.8%, reported here: https://savannah.gnu.org/bugs/?func=detailitem&item_id=64452
 encode_decode (fn, "", 15.0, 12157);
[swscaler @ 0x138933710] No accelerated colorspace conversion found from yuv420p to bgr24.
INFO: median(relative error) = 3.09%
INFO: size = 29.571 kB
!!!!! test failed
The difference between the expected (12.157 kB) and observed (29.571 kB) filesize of the written video exceeds the given relative threshold (30.0%). Please inspect '/tmp/oct-JPWf9X_rainbow_h264.mp4' manually. You should see a horizontal rainbow running from left to right.
***** test
 # mkv + default codec (= H264 on Debian GNU/Linux 12)
 fn = [tempname() "_rainbow_default.mkv"];
 # median(rel_err) = 0.71% on Debian GNU/Linux 12 on AMD Ryzen 7 5700X
 encode_decode (fn, [], 15.0, 12143); # allow 15.0% median error
[swscaler @ 0x138961710] No accelerated colorspace conversion found from yuv420p to bgr24.
INFO: median(relative error) = 11.81%
INFO: size = 29.582 kB
!!!!! test failed



Rafael Laboissière <rlaboiss>
Tue 08 Oct 2024 06:47:48 AM UTC, comment #10: 
Andreas Weber <andy1978>
Group Member
Sun 01 Sep 2024 10:21:53 AM UTC, comment #9: 

No, I do not have access to ppc hardware. I just looked at the file provided by Rafael.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Sun 01 Sep 2024 06:12:54 AM UTC, comment #8: 

Hi Dmitri, good catch.
I'm sorry but I've missed your message.

Do you have access to ppc64el hardware via ssh or have you been able to virtualize it using kvm/qemu?

After some debugging I think it's an upstream bug in ffmpeg on ppc64el and I need to create some demo using ffmpeg from CLI.

Andreas Weber <andy1978>
Group Member
Sun 23 Jul 2023 07:25:38 PM UTC, comment #7: 

I looked at the metadate on rainbow.mp4 generated on different platforms (ffmpeg -i or ffprobe -show_streams ).
They all have different bitrates. E.g.

ppc64el:

  Duration: 00:00:04.00, start: 0.000000, bitrate: 58 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 200x150, 55 kb/s, 30 fps, 30 tbr, 15360 tbn (default)

RaspberryPi4 Ubuntu 23.04:

  Duration: 00:00:04.00, start: 0.000000, bitrate: 23 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 200x150, 20 kb/s, 30 fps, 30 tbr, 15360 tbn (default)


amd64 CentOS Stream 9:

  Duration: 00:00:04.00, start: 0.000000, bitrate: 24 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 200x150, 21 kb/s, 30 fps, 30 tbr, 15360 tbn (default)


Just fyi.

Dmitri.
--


Dmitri A. Sergatskov <dasergatskov>
Sun 23 Jul 2023 03:06:44 PM UTC, comment #6: 

Thank you for providing the generated mp4. Although the file is bigger (29.4kB vs. 12.1kB on AMD64), it shows some strange purple artifacts between blue and red.

I think it's okay. that the test fails in this case because obviously there is a problem while encoding, perhaps some POWER8 CPU architecture related bug...

I'll try to create a raw video and then to transcode it in a qemu VM on ppc64el and then perhaps file a bugreport against ffmpeg.

-- Andy

Andreas Weber <andy1978>
Group Member
Sun 23 Jul 2023 02:17:38 PM UTC, comment #5: 

comment #2:

> Have you tried to visually inspect /tmp/rainbow.mp4 and is it visually comparable to the desired result?
>
> And do you have a better idea to implement checks rather than doing a encode/decode cycle? Perhaps I can switch to use a lossless/raw format or run thwo checks:
> 1.) Some lossless raw format (with low error threshold)
> 2.) mp4 container with H264/avc1 video codec (with higher threshold)
>
> Other ideas welcome.
>
> Do I have the chance to reproduce your test result on AMD64? Perhaps some qemu/kvm magic?


I built the package on one of the ppc64el Debian developer machine and generated the rainbow.mp4 file as in the BIST in VideoWriter. The resulting file is attached to this message.

(file #54952)

Rafael Laboissière <rlaboiss>
Sun 23 Jul 2023 08:48:08 AM UTC, comment #4: 

The problem reported in this bug report stroke again in version 2.1.1 of the video package, when compiled on a ppc64el system using ffmpeg 5 and g++ 13. The BIST for VideoWriter in the previous version (2.0.2) run correctly on ppc64el, but using ffmpeg 4 and g++ 11.

(BTW, please fix a typo in line 319 of inst/VideoWriter.m : “realtive” ⇒ “relative”.)

This is the relevant part of the build log:


[inst/VideoWriter.m]
>>>>> /<<PKGBUILDDIR>>/inst/VideoWriter.m
***** demo
 fn = fullfile (tempdir (), "sombrero.mp4");
 w = VideoWriter (fn);
 w.FrameRate = 50;
 open (w);
 z = sombrero ();
 hs = surf (z);
 axis manual
 nframes = 200;
 for ii = 1:nframes
   set (hs, "zdata", z * sin (2*pi*ii/nframes + pi/5));
   drawnow
   writeVideo (w, getframe (gcf));
 endfor
 close (w)
 printf ("Now run 'open %s' to read the video with your default video player or try 'demo VideoReader'!\n", fn);
***** test
 fn = fullfile (tempdir(), "rainbow.mp4");
 width = 200;
 height = 150;
 nframes = 120;
 p = permute (rainbow (width), [3 1 2]);
 raw_video = zeros (height, width, 3, nframes);
 w = VideoWriter (fn);
 for k=1:nframes
   ps = circshift (p, k * 6);
   img = uint8 (255 * repmat (ps, height, 1));
   raw_video (:, :, :, k) = img;
   writeVideo (w, img);
 endfor
 close (w)
 ## read video and compare
 clear -x raw_video fn
 r = VideoReader (fn);
 for k=1:size (raw_video, 4)
   img = readFrame (r);
   d = double (img) - raw_video(:,:,:,k);
   # FIXME: This write/read roundtrip check doesn't work well due to compression artifacts
   #        see also bug #58451 (https://savannah.gnu.org/bugs/?58451)
   #        what would be a better way?
   rel_err = sum (abs(d(:)))/numel(d)/255;
   warn_thres = 0.025;
   if (rel_err > warn_thres)
     warning ("The realtive deviation exceeds the given threshold (%.3f > %.3f).\n\
     Please inspect '%s' manually. You should see a horizontal rainbow running from left to right.", rel_err, warn_thres, fn);
   endif
   assert (rel_err < 2 * warn_thres)
 endfor
 close (r);
[swscaler @ 0x100115a7840] ALTIVEC: Color Space BGR24
warning: The realtive deviation exceeds the given threshold (0.148 > 0.025).
     Please inspect '/tmp/rainbow.mp4' manually. You should see a horizontal rainbow running from left to right.
warning: called from
    __test__ at line 29 column 6
    test at line 682 column 11
    /tmp/tmp.U4KNDwlVn4 at line 14 column 31

!!!!! test failed
assert (rel_err < 2 * warn_thres) failed
1 test, 0 passed, 0 known failure, 0 skipped


Rafael Laboissière <rlaboiss>
Fri 21 Jul 2023 06:59:07 AM UTC, comment #3: 

See also https://savannah.gnu.org/bugs/index.php?58451 where we increased the threshold for ppc64el three years ago.

Andreas Weber <andy1978>
Group Member
Fri 21 Jul 2023 05:30:04 AM UTC, comment #2: 

Hi Rafael, thank you for your report.

Have you tried to visually inspect /tmp/rainbow.mp4 and is it visually comparable to the desired result?

And do you have a better idea to implement checks rather than doing a encode/decode cycle? Perhaps I can switch to use a lossless/raw format or run thwo checks:
1.) Some lossless raw format (with low error threshold)
2.) mp4 container with H264/avc1 video codec (with higher threshold)

Other ideas welcome.

Do I have the chance to reproduce your test result on AMD64? Perhaps some qemu/kvm magic?

-- Andy

Andreas Weber <andy1978>
Group Member
Thu 20 Jul 2023 02:52:05 PM UTC, comment #1: 

Please, change the title of this bug report to:

[octave forge] (video) BIST in VideoWriter.m fails on ppc64el

Rafael Laboissière <rlaboiss>
Thu 20 Jul 2023 02:50:16 PM UTC, original submission:  

This is probably a resurrection of bug #58451. The ppc64el autobuilder for the Debian package octave-video (version 2.1.1) choked on the BIST in VideoWriter.m that writes/reads rainbow.mp4. The full log can be seen here and this is the relevant part:


***** test
 fn = fullfile (tempdir(), "rainbow.mp4");
 width = 200;
 height = 150;
 nframes = 120;
 p = permute (rainbow (width), [3 1 2]);
 raw_video = zeros (height, width, 3, nframes);
 w = VideoWriter (fn);
 for k=1:nframes
   ps = circshift (p, k * 6);
   img = uint8 (255 * repmat (ps, height, 1));
   raw_video (:, :, :, k) = img;
   writeVideo (w, img);
 endfor
 close (w)
 ## read video and compare
 clear -x raw_video fn
 r = VideoReader (fn);
 for k=1:size (raw_video, 4)
   img = readFrame (r);
   d = double (img) - raw_video(:,:,:,k);
   # FIXME: This write/read roundtrip check doesn't work well due to compression artifacts
   #        see also bug #58451 (https://savannah.gnu.org/bugs/?58451)
   #        what would be a better way?
   rel_err = sum (abs(d(:)))/numel(d)/255;
   warn_thres = 0.025;
   if (rel_err > warn_thres)
     warning ("The realtive deviation exceeds the given threshold (%.3f > %.3f).\n\
     Please inspect '%s' manually. You should see a horizontal rainbow running from left to right.", rel_err, warn_thres, fn);
   endif
   assert (rel_err < 2 * warn_thres)
 endfor
 close (r);
[swscaler @ 0x100115a7840] ALTIVEC: Color Space BGR24
warning: The realtive deviation exceeds the given threshold (0.148 > 0.025).
     Please inspect '/tmp/rainbow.mp4' manually. You should see a horizontal rainbow running from left to right.
warning: called from
    __test__ at line 29 column 6
    test at line 682 column 11
    /tmp/tmp.U4KNDwlVn4 at line 14 column 31

!!!!! test failed
assert (rel_err < 2 * warn_thres) failed


Rafael Laboissière <rlaboiss>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #57152:  out_h264-ffmpeg.mkv added by rlaboiss (1MiB - video/x-matroska)
file #57145:  oct-YQdbNJ_rainbow_default.mkv added by rlaboiss (29KiB - video/x-matroska)
file #54952:  rainbow.mp4 added by rlaboiss (29KiB - video/mp4)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by mmuetzel (Updated the item)
  • -email is unavailable- added by rlaboiss (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2025-04-21 rlaboiss Attached File- Added out_h264-ffmpeg.mkv, #57152
    2025-04-17 rlaboiss Attached File- Added oct-yifWhv_rainbow_h264.mp4, #57146
    2025-04-17 rlaboiss Attached File- Added oct-YQdbNJ_rainbow_default.mkv, #57145
    2023-07-23 rlaboiss Attached File- Added rainbow.mp4, #54952
    2023-07-20 mmuetzel Summary[octave forge] (struct) Fix cleaning of files in src/Makefile.in [octave forge] (video) BIST in VideoWriter.m fails on ppc64el

    Back to the top

    Powered by Savane 3.15-e6e5.
    Corresponding source code