nurupo / vlc-pause-click-plugin

Plugin for VLC that pauses/plays video on mouse click
GNU Lesser General Public License v2.1
928 stars 63 forks source link

Mac ARM/Universal binary support request #81

Open kjoonlee opened 3 years ago

kjoonlee commented 3 years ago

Is your feature request related to a problem? Please describe

Plugin doesn’t function when running arm64 binary or universal binary of VLC on an M1 Mac

Describe the solution you'd like

Plugin would come in 3 versions: intel, arm64, universal, same as how VLC binaries are distributed

Describe alternatives you've considered

Or it could come in 2 versions: intel and arm64 Tried to figure out if I could compile it for myself but I could’t figure out how to get the SDK for VLC 3.0

Additional context

In the mean time if you could update the documentation for VLC 3.0 macOS compilation that would be cool too

nurupo commented 2 years ago

We rely on the CI to make macOS builds, and neither Travis-CI nor GitHub Actions provide macOS ARM runners, so this is not something that can be easily added. If someone figures out how to cross-compile the plugin from x86-64 macOS to ARM macOS on the CI -- please feel free to contribute. It's not something I want to do myself and I wouldn't be able to test the resulting binaries as I don't own an ARM mac.

Tried to figure out if I could compile it for myself but I could’t figure out how to get the SDK for VLC 3.0

Not sure if anything changed for ARM, but for x86-64 we had to piece the SDK together by combining files from macOS and Windows SDKs like so:

brew update
brew install p7zip
mkdir -p tmp/tmp
cd tmp/tmp
wget https://download.videolan.org/pub/videolan/vlc/3.0.0/macosx/vlc-3.0.0.dmg
# extracting contents of a .dmg file using 7-zip is more of a hack, and while it works 7z exits with an error code we want to suppress
7z x "*.dmg" "*/VLC.app/Contents/MacOS" || true
mv */VLC.app/Contents/MacOS/lib ..
mv */VLC.app/Contents/MacOS/include ..
cd ..
rm -rf ./tmp
# in contrast to Windows VLC including a very nice and complete sdk directory,
# macOS VLC doesn't package .pc files, plugin headers and in 2.1.0 libvlc_version.h is not generated off libvlc_version.h.in.
# it just packages libvlc.dylib, libvlccore.dylib and libvlc headers.
# we grab the missing pieces from the Windows VLC, there shouldn't be anything platform-specific in those so it should work
wget https://download.videolan.org/pub/videolan/vlc/3.0.0/win64/vlc-3.0.0-win64.7z -O vlc-3.0.0-win64.7z
7z x "*.7z" -o* "*/sdk"
mv vlc-3.0.0-win64/*/sdk/include/vlc/libvlc_version.h include/vlc/
mv vlc-3.0.0-win64/*/sdk/include/vlc/plugins include/vlc
mv vlc-3.0.0-win64/*/sdk/lib/pkgconfig lib
rm -rf ./vlc-3.0.0-win64*
# fix paths in .pc files
sed -i "" "s|^prefix=.*|prefix=$PWD|g" lib/pkgconfig/*.pc
export PKG_CONFIG_PATH="${PWD}/lib/pkgconfig"
cd lib
# fix library symlink
ln -sf libvlccore.*.dylib libvlccore.dylib
cd ../..
make OS=macOS
zip -j vlc-3.0-macosx.zip libpause_click_plugin.dylib
kjoonlee commented 2 years ago

Sorry for the late response but I could get it running in no time!

I just had to download an arm64 disk image instead of an intel one:

wget https://get.videolan.org/vlc/3.0.17.3/macosx/vlc-3.0.17.3-arm64.dmg

After compiling the arm64 version, it just worked, but I could also use lipo to join it together with the intel version and it worked with either arm64/intel versions of macOS VLC:

lipo arm64/libpause_click_plugin.dylib x86_64/libpause_click_plugin.dylib -create -output libpause_click_plugin.dylib
cp libpause_click_plugin.dylib /Applications/VLC.app/Contents/MacOS/plugins/ 
sergioyc40 commented 2 years ago

Sorry for the late response but I could get it running in no time!

I just had to download an arm64 disk image instead of an intel one:

wget https://get.videolan.org/vlc/3.0.17.3/macosx/vlc-3.0.17.3-arm64.dmg

After compiling the arm64 version, it just worked, but I could also use lipo to join it together with the intel version and it worked with either arm64/intel versions of macOS VLC:

lipo arm64/libpause_click_plugin.dylib x86_64/libpause_click_plugin.dylib -create -output libpause_click_plugin.dylib
cp libpause_click_plugin.dylib /Applications/VLC.app/Contents/MacOS/plugins/ 

It was not so clear to me, can you make an usage instruction explained in detail for this? I have a mac M1 Arm and I've been able to use pause_click only with the Intel version! Thanks in advance!

kjoonlee commented 2 years ago

If you trust me, you can use this: vlc-3.0-macosx-all.zip

Just unzip it and copy the arm64/universal version into an arm64/universal version of VLC and it will work.

If you don't trust me, you will have to compile the plugin yourself. I had Xcode and Homebrew installed. You will need to download the https://github.com/nurupo/vlc-pause-click-plugin/releases/tag/2.2.0 source tar.gz file, unpack it, then save nurupo's script as a file, change line 5 to download the arm64 DMG instead of the intel DMG, then run it.

You will need to be familiar with saving and running shell scripts.

kjoonlee commented 2 years ago

If you've been using the intel version of VLC and you want to switch to the arm64 version:

Get the arm64 version of VLC running first, then shut it down and copy the plugin.

If you copy the plugin first before getting the arm64 version to run, then the app verification will fail and you will need to delete the app and reinstall from the DMG again.

chrisgrieser commented 2 years ago

If you trust me, you can use this: vlc-3.0-macosx-all.zip

Thank you so much, after having tried a bunch of methods, this is literally the first time I got it to work. You should make a PR to the main repo with this fix.

kjoonlee commented 2 years ago

Making cc always use -target arm64-apple-macos10.12 seems to do the job in cross-compiling the plugin. Proof-of-concept steps:

  1. Build x86_64 version, save it
  2. Remove temp files
  3. Change Makefile so that it will build arm64 version
  4. Build arm64 version, save it
  5. Combine x86_64 version and arm64 version

Proof-of-concept script (inefficient because it downloads the SDK twice, dumb because I don't really understand build procedures or Make):

#!/bin/bash
brew update
brew install p7zip

rm -rf tmp
make OS=macOS clean

mkdir -p tmp/tmp
cd tmp/tmp
wget https://download.videolan.org/pub/videolan/vlc/3.0.0/macosx/vlc-3.0.0.dmg
# extracting contents of a .dmg file using 7-zip is more of a hack, and while it works 7z exits with an error code we want to suppress
7z x "*.dmg" "*/VLC.app/Contents/MacOS" || true
mv */VLC.app/Contents/MacOS/lib ..
mv */VLC.app/Contents/MacOS/include ..
cd ..
rm -rf ./tmp
# in contrast to Windows VLC including a very nice and complete sdk directory,
# macOS VLC doesn't package .pc files, plugin headers and in 2.1.0 libvlc_version.h is not generated off libvlc_version.h.in.
# it just packages libvlc.dylib, libvlccore.dylib and libvlc headers.
# we grab the missing pieces from the Windows VLC, there shouldn't be anything platform-specific in those so it should work
wget https://download.videolan.org/pub/videolan/vlc/3.0.0/win64/vlc-3.0.0-win64.7z -O vlc-3.0.0-win64.7z
7z x "*.7z" -o* "*/sdk"
mv vlc-3.0.0-win64/*/sdk/include/vlc/libvlc_version.h include/vlc/
mv vlc-3.0.0-win64/*/sdk/include/vlc/plugins include/vlc
mv vlc-3.0.0-win64/*/sdk/lib/pkgconfig lib
rm -rf ./vlc-3.0.0-win64*
# fix paths in .pc files
sed -i "" "s|^prefix=.*|prefix=$PWD|g" lib/pkgconfig/*.pc
export PKG_CONFIG_PATH="${PWD}/lib/pkgconfig"
cd lib
# fix library symlink
ln -sf libvlccore.*.dylib libvlccore.dylib
cd ../..
make OS=macOS
mkdir x86_64
mv libpause_click_plugin.dylib x86_64

rm -rf tmp
make OS=macOS clean

mkdir -p tmp/tmp
cd tmp/tmp
wget https://get.videolan.org/vlc/3.0.17.3/macosx/vlc-3.0.17.3-arm64.dmg
# extracting contents of a .dmg file using 7-zip is more of a hack, and while it works 7z exits with an error code we want to suppress
7z x "*.dmg" "*/VLC.app/Contents/MacOS" || true
mv */VLC.app/Contents/MacOS/lib ..
mv */VLC.app/Contents/MacOS/include ..
cd ..
rm -rf ./tmp
# in contrast to Windows VLC including a very nice and complete sdk directory,
# macOS VLC doesn't package .pc files, plugin headers and in 2.1.0 libvlc_version.h is not generated off libvlc_version.h.in.
# it just packages libvlc.dylib, libvlccore.dylib and libvlc headers.
# we grab the missing pieces from the Windows VLC, there shouldn't be anything platform-specific in those so it should work
wget https://download.videolan.org/pub/videolan/vlc/3.0.0/win64/vlc-3.0.0-win64.7z -O vlc-3.0.0-win64.7z
7z x "*.7z" -o* "*/sdk"
mv vlc-3.0.0-win64/*/sdk/include/vlc/libvlc_version.h include/vlc/
mv vlc-3.0.0-win64/*/sdk/include/vlc/plugins include/vlc
mv vlc-3.0.0-win64/*/sdk/lib/pkgconfig lib
rm -rf ./vlc-3.0.0-win64*
# fix paths in .pc files
sed -i "" "s|^prefix=.*|prefix=$PWD|g" lib/pkgconfig/*.pc
export PKG_CONFIG_PATH="${PWD}/lib/pkgconfig"
cd lib
# fix library symlink
ln -sf libvlccore.*.dylib libvlccore.dylib
cd ../..
sed -i "" "s|CC = cc|CC = cc -target arm64-apple-macos10.12|" Makefile
make OS=macOS
mkdir arm64
mv libpause_click_plugin.dylib arm64
mkdir universal
lipo arm64/libpause_click_plugin.dylib x86_64/libpause_click_plugin.dylib -create -output universal/libpause_click_plugin.dylib
sed -i "" "s|CC = cc -target arm64-apple-macos10.12|CC = cc|" Makefile