#1103936 ffmpeg: Wrong result for h264 encoding on ppc64el

Package:
ffmpeg
Source:
ffmpeg
Description:
Tools for transcoding, streaming and playing of multimedia files
Submitter:
Rafael Laboissière
Date:
2025-09-23 01:27:04 UTC
Severity:
normal
Tags:
#1103936#5
Date:
2025-04-23 05:00:19 UTC
From:
To:
Encoding a video file with the h264 codec on a ppc64el system results
in a video full of artifacts. For instance:

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

The resulting file is attached to this bug report.

The command above works fine on my amd64 system.

This bug is causing the octave-video to FTBFS on ppc64el (Bug#1103757).

Best,

Rafael Laboissière

#1103936#14
Date:
2025-05-08 18:01:00 UTC
From:
To:
Hello Rafael,

I tested the following command on a ppc64el system:

     ffmpeg -i vtest.avi -vcodec libx264 -to 2 out_h264.mkv

The resulting video contains visible artifacts. Running the same command
on an amd64 system produces correct output.

Test system (ppc64el):
   OS: Debian GNU/Linux 12 (bookworm)
   Kernel: Linux 6.1.0-25
   gcc version 12.2.0
   ffmpeg version 7.1.1-1

I’m attaching the ffmpeg debug log and a sample frame from the output.
I will test on Debian Trixie and share the results.

Thanks and Regards,
Trupti

#1103936#19
Date:
2025-05-26 15:14:57 UTC
From:
To:
Hello all,

Bug #1103936 update (ref: Trupti, msg #14):

libx264's Altivec code on ppc64el was suspected of causing video
artifacts.
The x264 source package (0.164.3108+git31e19f9-2) was recompiled with
assembly optimizations disabled.

The following change was observed in the ffmpeg debug log:
[libx264 @ 0x10017342670] using cpu capabilities: Altivec →
[libx264 @ 0x100275b2670] using cpu capabilities: none!

Testing with the command:
ffmpeg -i vtest.avi -vcodec libx264 -to 2 out_h264.mkv using this custom
libx264:

1. Resulting video is clear; artifacts are no longer present.

2. ffmpeg debug log confirms libx264 no longer reports using Altivec.

This confirms the bug lies in libx264's Altivec code path on ppc64el.

Test system details are as per message #14.

Attaching the ffmpeg debug log and the output .mkv video without
artifacts.

#1103936#26
Date:
2025-05-31 09:15:12 UTC
From:
To:
Hi Trupti,

Thanks for nailing down the problem.

I have a few comments about the Control headers in your message:

* Trupti <trupti@linux.ibm.com> [2025-05-26 20:44]:

Actually, I think it's the other way around. The problem originates from
the x264 package and affects ffmpeg. Furthermore, it does not seem to
have been fixed, as pretended above. By the way, the syntax of the
"fixed" command above is not correct, since "fixed" only accepts
"bugnumber" and "version" arguments (see
https://www.debian.org/Bugs/server-control#fixed).

I would rather do this:

     affects 1103936 - src:x264
     reassign 1103936 src:x264 0.164.3108+git31e19f9-2
     retitle 1103936 x264: Wrong result for h264 encoding on ppc64el
     affects 1103936 + ffmpeg

If there are no objections, I will issue these commands to the BTS.

Best,

Rafael Laboissière

#1103936#31
Date:
2025-06-02 06:01:30 UTC
From:
To:
Hi Rafael,

Sorry for the confusion earlier-as the issue still persist because of
x264 package and I will look into it.
Also, thanks for pointing out the syntax mistake and will make sure to
correct it moving forward.

No objections from my side. You may issue the commands.

Thanks and Regards,
Trupti

#1103936#36
Date:
2025-06-09 04:35:54 UTC
From:
To:
* Trupti <trupti@linux.ibm.com> [2025-06-02 11:31]:

Done!

Best,

Rafael Laboissière

#1103936#53
Date:
2025-08-22 05:27:12 UTC
From:
To:
Hello,

I've investigated this build failure on ppc64el and have confirmed the
root cause is a bug in the Altivec code within libx264.

While recompiling libx264 with assembly disabled (--disable-asm) fixes
the build, it's not a viable solution due to a massive performance
regression. A benchmark I ran showed that the:
6.9s with Altivec and 54.3s without Altivec .

Given the performance impact, how would you recommend we proceed with
resolving this?


Thanks and Regards,
Trupti

#1103936#58
Date:
2025-09-04 16:58:53 UTC
From:
To:
Hi Trupti,

I am not involved in libx264 maintenance, I'm lurking as a Release Team
member. Reporting upstream sounds like a smart move, maybe upstream
already even found and fixed the issue, if not they may be helpful. I
guess somebody with knowledge of ppc64el assembly needs to have a look
and come up with a patch. Seems like a fitting job for a porter.

An alternative route is to check for newer upstream versions. This
library hasn't seen a Debian update since one year ago. Might be that
the problem is already fixed.

Paul

#1103936#63
Date:
2025-09-05 12:47:26 UTC
From:
To:
Hello,

Thanks for your suggestion.

I tried compiling FFmpeg with the new version of libx264. The test video
no longer shows any artifacts, but it is not using Altivec
optimizations, so the conversion takes more time.

I will look into this further.

#1103936#68
Date:
2025-09-10 09:06:39 UTC
From:
To:

Hello,

I tested the issue described earlier using x264 r3222 (upstream new
version) with FFmpeg 7.1.1 on Debian Trixie (ppc64el).

The artifacts in video encoding still persist when using:

ffmpeg -i vtest.avi -vcodec libx264 -to 2 out_h264.mkv


I will report this issue upstream.
This is just an update to confirm the issue remains in the newer
version.


Thanks and Regards,
Trupti

#1103936#71
Date:
2025-09-14 21:11:25 UTC
From:
To:
Hello,

Bug #1103936 in x264 reported by you has been fixed in the
Git repository and is awaiting an upload. You can see the commit
message below and you can check the diff of the fix at:

https://salsa.debian.org/multimedia-team/x264/-/commit/5702d41b82e955ff1c4a8f8912ec432eefe85b87
------------------------------------------------------------------------
Disable optimizations on powerpc architectures

Closes: #1103936
------------------------------------------------------------------------

(this message was generated automatically)
-- 
Greetings

https://bugs.debian.org/1103936

#1103936#78
Date:
2025-09-15 11:26:28 UTC
From:
To:
Hello @Sebastian Ramacher,
I reviewed the commit and observed that disabling the ASM optimization could significantly affect performance on the ppc64el architecture.
I am currently gathering benchmark results to quantify the performance impact and will share them shortly.
Please let me know if you would like me to provide additional details.
Best regards,
Trupti Shirsat
------------------------------------------------------------------------ Disable optimizations on powerpc architectures Closes: #1103936 ------------------------------------------------------------------------ (this message was generated automatically) -- Greetings https://bugs.debian.org/1103936
#1103936#83
Date:
2025-09-15 12:28:21 UTC
From:
To:
Hi Trupti,

No disagreement here. But the ASM optimization was disabled on powerpc, ppc64
and ppc64el because the testsuite is failing otherwise as the code is broken.

See [1] and [2].

If someone at IBM could take a look at the code and fix the problems, that would
be greatly appreciated. And if you could make sure that it works on older baselines
as well, that would be awesome.

Thanks,
Adrian

#1103936#88
Date:
2025-09-15 18:14:53 UTC
From:
To:
Hello Adrian,


Thanks for sharing the resources. I will look into this.
Yes, I understand that some of testsuite are failing and causing FTBFS
on powerpc,ppc64 and ppc64el.

Yes, definitely. I’ll take a look at the code and discuss it with the
right team to work on fixing the issues. We’ll also ensure it’s
compatible with older baselines. I’ll update you soon.

Thanks,
Trupti

#1103936#93
Date:
2025-09-15 18:26:16 UTC
From:
To:
Hi,

You're welcome!

Thanks! I really appreciate that there is finally someone willing to help
with architectures in Debian that are not amd64 and arm64.

I have started to get the impression I'm alone in this world.

Adrian

#1103936#102
Date:
2025-09-20 22:39:26 UTC
From:
To:
# forgot to close the bug in the changelog
close 1103936 2:0.165.3222+gitb35605ac-2
thanks

#1103936#107
Date:
2025-09-21 20:09:57 UTC
From:
To:
* Sebastian Ramacher <sramacher@debian.org> [2025-09-21 00:39]:

Thank you for your work, but unfortunately the bug persists. On the
pcc64el host platti.debian.org, I ran the following commands inside a sid chroot:

     (sid_ppc64el-dchroot)rafael@platti:~$ dpkg -l ffmpeg libx264-165
     Desired=Unknown/Install/Remove/Purge/Hold
     | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
     |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
     ||/ Name                Version                    Architecture Description
     +++-===================-==========================-============-================================================================
     ii  ffmpeg              7:7.1.2-1                  ppc64el      Tools for transcoding, streaming and playing of multimedia files
     ii  libx264-165:ppc64el 2:0.165.3222+gitb35605ac-2 ppc64el      x264 video coding library
     (sid_ppc64el-dchroot)rafael@platti:~$ wget https://raw.githubusercontent.com/opencv/opencv/master/samples/data/vtest.avi
     (sid_ppc64el-dchroot)rafael@platti:~$ ffmpeg -i vtest.avi -vcodec libx264 -to 2 out_h264.mkv

and the resulting file (attached to this message) still has the same
artifacts as before.

Best,

Rafael Laboissière

#1103936#118
Date:
2025-09-22 07:29:43 UTC
From:
To:
Hello,

I tried with below versions of ffmpeg and lib264. And didn't get any artifacts in the video.
I have attached the output video.


trupti@debian64:~$ dpkg -l ffmpeg libx264-165
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                Version                    Architecture Description
+++-===================-==========================-============-================================================================
ii  ffmpeg              7:7.1.1-1+b1               ppc64el      Tools for transcoding, streaming and playing of multimedia files
ii  libx264-165:ppc64el 2:0.165.3222+gitb35605ac-3 ppc64el      x264 video coding library


Thank you for your work, but unfortunately the bug persists. On the
pcc64el host platti.debian.org, I ran the following commands inside a sid chroot:

     (sid_ppc64el-dchroot)rafael@platti:~$ dpkg -l ffmpeg libx264-165
     Desired=Unknown/Install/Remove/Purge/Hold
     | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
     |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
     ||/ Name                Version                    Architecture Description
     +++-===================-==========================-============-================================================================
     ii  ffmpeg              7:7.1.2-1                  ppc64el      Tools for transcoding, streaming and playing of multimedia files
     ii  libx264-165:ppc64el 2:0.165.3222+gitb35605ac-2 ppc64el      x264 video coding library
     (sid_ppc64el-dchroot)rafael@platti:~$ wget https://raw.githubusercontent.com/opencv/opencv/master/samples/data/vtest.avi
     (sid_ppc64el-dchroot)rafael@platti:~$ ffmpeg -i vtest.avi -vcodec libx264 -to 2 out_h264.mkv

and the resulting file (attached to this message) still has the same
artifacts as before.

Best,

Rafael Laboissière

#1103936#123
Date:
2025-09-22 15:07:37 UTC
From:
To:
Could you please also test with ffmpeg version 7.1.2? This is the only
difference that I see between our two cases.

Best,

Rafael

* Trupti Shirsat <Trupti.Shirsat@ibm.com> [2025-09-22 07:29]:

#1103936#128
Date:
2025-09-22 15:40:59 UTC
From:
To:
Note the revision change in libx264-165 (from -2 to -3). The change in
-3 will be uploaded once -2 has migrated to testing.

Cheers

#1103936#133
Date:
2025-09-23 01:24:35 UTC
From:
To:
We believe that the bug you reported is fixed in the latest version of
x264, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 1103936@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Sebastian Ramacher <sramacher@debian.org> (supplier of updated x264 package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Sun, 21 Sep 2025 23:45:22 +0200
Source: x264
Architecture: source
Version: 2:0.165.3222+gitb35605ac-3
Distribution: unstable
Urgency: medium
Maintainer: Debian Multimedia Maintainers <debian-multimedia@lists.debian.org>
Changed-By: Sebastian Ramacher <sramacher@debian.org>
Closes: 1103936
Changes:
 x264 (2:0.165.3222+gitb35605ac-3) unstable; urgency=medium
 .
   * debian/control:
     - Add myself to uploaders
     - Move x264 to video section
   * debian/rules: Refactor configure flag handling
     - mips64el is no longer a release architecture
     - Remove space handling for sparc which is no longer applicable
     - Hard-code handling for armhf
     - Hard-code handling for i386
     - Fix handling of powerpc architectures (Closes: #1103936)
   * debian/: Remove static library
Checksums-Sha1:
 139a537bdfde2874c1ae620312d6376cc6bc98be 1777 x264_0.165.3222+gitb35605ac-3.dsc
 404bd8f827b1b7c1f10c1e783f2bb5e8e310d9d1 23200 x264_0.165.3222+gitb35605ac-3.debian.tar.xz
 4804b6d28a9317b5e200455618711732535c6ae0 9836 x264_0.165.3222+gitb35605ac-3_source.buildinfo
Checksums-Sha256:
 8811c0a7b17193fee2a837e7c8192ad1247263acc21e217be57484c73255e2b4 1777 x264_0.165.3222+gitb35605ac-3.dsc
 a0799e32c60e266ba5e7266c3e30c3e04490f2e167fece4123c84ed320ec8ef9 23200 x264_0.165.3222+gitb35605ac-3.debian.tar.xz
 f3f3eec316cbd77d3b326004fb3b96d85d8655813da03a4a04e2711d19e44e78 9836 x264_0.165.3222+gitb35605ac-3_source.buildinfo
Files:
 8252729954a90467fb21d6f2c8eb309b 1777 libs optional x264_0.165.3222+gitb35605ac-3.dsc
 6bd222a8cc0949d4fd3f0a3528b27a9e 23200 libs optional x264_0.165.3222+gitb35605ac-3.debian.tar.xz
 24c0f5841bad37b880a68e2e89435560 9836 libs optional x264_0.165.3222+gitb35605ac-3_source.buildinfo
-----BEGIN PGP SIGNATURE-----

iHUEARYKAB0WIQRCYn6EHZln2oPh+pAhk2s2YA/NiQUCaNByDwAKCRAhk2s2YA/N
ialtAQDPWfzIworRQrVOa5kzreJzQatEJzjdzfrVyw3DRrGqvQEA7A7eAjAa3eYH
g7sL+w33BgQ80bq2jFm1alSRAQSPaQQ=
=J+O4
-----END PGP SIGNATURE-----