sindresorhus / Gifski

🌈 Convert videos to high-quality GIFs on your Mac
https://sindresorhus.com/gifski
MIT License
7.79k stars 295 forks source link

Support building for Apple Silicon #236

Closed sindresorhus closed 3 years ago

sindresorhus commented 3 years ago

@kornelski I didn't want to deal with the complicated Xcode run stuff. A makefile was much easier.


Fixes #215

sindresorhus commented 3 years ago

Test build: Gifski-universal.zip


@leejongyoung Can you test the build?

ghost commented 3 years ago

Test environment

The app speed is very fast. Launcher runs safely and work 😄

But the graphic is broken in the gif 🥺 Bugs occur on all video extensions

Screen Shot 2021-03-06 at 9 37 40 PM Screen Shot 2021-03-06 at 9 37 33 PM

Result

Screen-Recording-2021-03-06-at-9 36 55-PM

kornelski commented 3 years ago

I've checked that the gifski library works fine on M1 with ffmpeg, so the problem is most likely on the app side.

The pinkish color and extra transparency looks like the video has been decoded to ARGB instead of RGBA.

sindresorhus commented 3 years ago

So apparently the underlying storage format of CGImage is not guaranteed to be consistent. We have just been lucky so far. I have tried to convert it to a proper format in https://github.com/sindresorhus/Gifski/pull/236/commits/23ca26defad6202037ac1a28e9ab54809977ee62, but I don't have a Apple Silicon Mac, so it would be great if you could test this:

Gifski-universal2.zip

ghost commented 3 years ago

@sindresorhus @kornelski It works very well It is now available for release I want to see you soon on the App Store

Screen Recording 2021-03-11 at 6 39 44 PM

sindresorhus commented 3 years ago

So this required a deep dive into the topic. I finally discovered that vImage supports converting between different pixel formats, and that it, in contrast to CGContext, supports non-premultiplied alpha. Another benefit of using vImage is that it's super optimized.

So here's a new (and hopefully last) test build: Gifski-universal3.zip

@leejongyoung Can you confirm that you saw the "Gifski on Apple Silicon" message when launching the new build? And can you try converting a video and copy-paste the text that shows up in the dialog when you start converting?

ghost commented 3 years ago

Yes it works

But I want the message "Gifski on Apple Silicon" to be executed only for the first time. Message is always output in case of new execution

I'll upload the debugging dialog as a picture

Screen Shot 2021-03-12 at 21 00 30 Screen Shot 2021-03-12 at 21 04 05
sindresorhus commented 3 years ago

Thanks 🙏


But I want the message "Gifski on Apple Silicon" to be executed only for the first time. Message is always output in case of new execution

Yes. It will only be shown once.

sindresorhus commented 3 years ago

So it looks like Apple took advantage of the new architecture by making CGImage stored in little-endian, which is faster, since it's the native byte order. On Intel Macs, it's stored in big-median for unknown legacy reasons.

sindresorhus commented 3 years ago

@kornelski Feedback welcome on the last commit if you see anything incorrect.

haakonstorm commented 3 years ago

Hi guys, just wanted to add another m1 to the test (mba13/16gb).

Screenshot of QuickTime Player (13-03-2021, 13-50-08) Screenshot of Gifski (13-03-2021, 13-48-17) Screenshot of Gifski (13-03-2021, 13-51-28) Screenshot of Gifski (13-03-2021, 13-52-20)

The resulting .gif:

Screen Recording 2021-03-13 at 13 45 34

kornelski commented 3 years ago

Yeah, the output looks like it has a wrong width/stride specified.

sindresorhus commented 3 years ago

@haakonstorm Thanks for reporting! I found the issue and fixed it.

New build: Gifski-universal5.zip

haakonstorm commented 3 years ago

A+++ will buy again !

input

sindresorhus commented 3 years ago

Thanks, everyone, for the help with testing this 🙏