kapitainsky / handbreak-RaspberryPi

building handbreak on raspberry pi including x265
7 stars 5 forks source link

Handbrake v1.3.2 on RaspberryPi 4 with Raspian Buster #2

Open der-ule opened 4 years ago

der-ule commented 4 years ago

Hi there,

I came across your instructions today and I was able to successfully compile Handbrake v1.3.2 on the Raspberry Pi 4 with Raspian Buster, I just needed to add a two dependencies, otherwise, everything worked perfectly, thank you!

1. Missing dependencies meson and libnuma-dev

sudo apt-get install git autoconf automake build-essential cmake libass-dev libbz2-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libharfbuzz-dev libjansson-dev liblzma-dev libmp3lame-dev libogg-dev libopus-dev libsamplerate-dev libspeex-dev libtheora-dev libtool libtool-bin libvorbis-dev libx264-dev libxml2-dev m4 make patch pkg-config python tar yasm zlib1g-dev libvpx-dev xz-utils bzip2 zlib1g meson libnuma-dev

3. Download source code directly from official website

https://handbrake.fr/rotation.php?file=HandBrake-1.3.2-source.tar.bz2

I hope this helps anyone trying this.

rafaelmaeuer commented 4 years ago

Hey thank you for sharing this.

I tried to rebuild it with your updates but make -j $(nproc) fails with following error:

/usr/bin/ld: ./contrib/lib/libx265.a(cpu.cpp.o): in function `x265::cpu_detect(bool)':
cpu.cpp:(.text+0x24): undefined reference to `x265_cpu_fast_neon_mrc_test'
/usr/bin/ld: ./contrib/lib/libx265.a(cpu.cpp.o): in function `x265_10bit::cpu_detect(bool)':
cpu.cpp:(.text+0x24): undefined reference to `x265_10bit_cpu_fast_neon_mrc_test'
/usr/bin/ld: ./contrib/lib/libx265.a(cpu.cpp.o): in function `x265_12bit::cpu_detect(bool)':
cpu.cpp:(.text+0x24): undefined reference to `x265_12bit_cpu_fast_neon_mrc_test'
collect2: error: ld returned 1 exit status
make: *** [../test/module.rules:47: HandBrakeCLI] Fehler 1

Any idea how to fix this?

der-ule commented 4 years ago

Can it be that you forgot STEP 6 ?

https://github.com/kapitainsky/handbreak-RaspberryPi#6-we-have-to-make-quick-and-dirty-hack-to-x265-source-code

Otherwise I wouldn't know, I just followed all the step as described and worked perfectly (after the extra dependencies).

Good luck.

rafaelmaeuer commented 4 years ago

Thanks for the fast reply!

No, I pay attention to every step. But I have repeated the process several times and tried to skip some steps without luck.

Step 6 has a different path though: ./contrib/x265/x265_3.2.1/source/common/primitives.cpp. Might the x265 version make the difference? Did you compile with x265_3.0 instead of x265_3.2.1?

For me x265 is irrelevant, I only need x264, is it possible to disable x265 on compilation?

der-ule commented 4 years ago

I just gave it another try and it worked fine, here are my steps from step #3:

wget https://github.com/HandBrake/HandBrake/releases/download/1.3.2/HandBrake-1.3.2-source.tar.bz2

tar -xf HandBrake-1.3.2-source.tar.bz2

cd HandBrake-1.3.2/

echo "X265_8.CONFIGURE.extra += -DENABLE_ASSEMBLY=OFF -DENABLE_PIC=ON -DENABLE_AGGRESSIVE_CHECKS=ON -DENABLE_TESTS=ON -DCMAKE_SKIP_RPATH=ON" >> ./contrib/x265_8bit/module.defs && echo "X265_10.CONFIGURE.extra += -DENABLE_ASSEMBLY=OFF -DENABLE_PIC=ON -DENABLE_AGGRESSIVE_CHECKS=ON -DENABLE_TESTS=ON -DCMAKE_SKIP_RPATH=ON" >> ./contrib/x265_10bit/module.defs && echo "X265_12.CONFIGURE.extra += -DENABLE_ASSEMBLY=OFF -DENABLE_PIC=ON -DENABLE_AGGRESSIVE_CHECKS=ON -DENABLE_TESTS=ON -DCMAKE_SKIP_RPATH=ON" >> ./contrib/x265_12bit/module.defs && echo "X265.CONFIGURE.extra += -DENABLE_ASSEMBLY=OFF -DENABLE_PIC=ON -DENABLE_AGGRESSIVE_CHECKS=ON -DENABLE_TESTS=ON -DCMAKE_SKIP_RPATH=ON" >> ./contrib/x265/module.defs

./configure --launch-jobs=$(nproc) --disable-gtk --disable-nvenc --disable-qsv --enable-fdk-aac

cd build/

make -j $(nproc) (wait for downloads to finish and interrupt)

nano ./contrib/x265/x265_3.2.1/source/common/primitives.cpp

Modify the file to look like this (change == to !=)

tail -6 ./contrib/x265/x265_3.2.1/source/common/primitives.cpp
#if X265_ARCH_ARM != 0
void PFX(cpu_neon_test)(void) {}
int PFX(cpu_fast_neon_mrc_test)(void) { return 0; }
#endif // X265_ARCH_ARM
}
#endif

make clean

make -j $(nproc)

And here my OS information

pi@raspberrypi:~/test_handbrake/HandBrake-1.3.2/make $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
pi@raspberrypi:~/test_handbrake/HandBrake-1.3.2/make $ uname -a
Linux raspberrypi 4.19.97-v7l+ #1294 SMP Thu Jan 30 13:21:14 GMT 2020 armv7l GNU/Linux

I hope this helps you, for the rest, the author posted a couple of links as reference, you may find more information in them.

Good luck.

rafaelmaeuer commented 4 years ago

Wow this time it run through, I explicitly executed Step 2 again:

sudo curl -L 'http://ftp.debian.org/debian/pool/main/n/nasm/nasm_2.14-1_armhf.deb' -o /var/cache/apt/archives/nasm_2.14-1_armhf.deb && sudo dpkg -i /var/cache/apt/archives/nasm_2.14-1_armhf.deb

But not sure if this made the difference, regarding the steps you mentioned above... Thanks for your help! As next step I try to build the user-interface too...

der-ule commented 4 years ago

I am glad that it worked out, I did not repeated steps #1 and #2 above because it is still the same raspberry :)

BTW I just gave it a try with the new v1.3.3 release, it works the same: https://handbrake.fr/rotation.php?file=HandBrake-1.3.3-source.tar.bz2

kapitainsky commented 4 years ago

I do not have running RPi at the moment to test but I can see that there is newer nasm, so maybe in step 2 replacing nasm_2.14-1_armhf.deb with nasm_2.15.05-1_armhf.deb can improve situation.

kapitainsky commented 4 years ago

I also thing that I should update step 3 - as I understand from your posts it works perfectly now with HandBreak 1.3.2 or 1.3.3 and it is not required to cherry pick specific commit

kapitainsky commented 4 years ago

@rafaelmaeuer could you please share if you succeeded building UI?

der-ule commented 4 years ago

That's right v1.3.2 and v1.3.3 compile without a problems:

pi@raspberrypi:~/test_handbrake/HandBrake-1.3.3/build $ ./HandBrakeCLI --version
[12:01:41] hb_init: starting libhb thread
[12:01:41] thread b3d702f0 started ("libhb")
HandBrake 1.3.3
rafaelmaeuer commented 4 years ago

@kapitainsky I was successful in building the GUI for v1.3.3. Thanks again for sharing this! Find all updates in my fork: https://github.com/rafaelmaeuer/handbrake-raspberry-pi

kapitainsky commented 4 years ago

@rafaelmaeuer do you mind if I include GUI parts in my guide?

rafaelmaeuer commented 4 years ago

no feel free :)

plusterkopp commented 3 years ago

Would it be possible to somehow use the latest x265 with aarch64 assembly? http://x265.org/faster-arm64-encodes-using-x265/ Not that the speedup is too great. But can one take a prebuilt set of x265 libs and just compile the rest of handbrake?

Rowley2504 commented 1 year ago

Just got 1.6.1 to build

sudo apt install libturbojpeg0-dev git autoconf automake build-essential cmake libass-dev libbz2-dev libfontconfig1-dev libfreetype6-dev libfribidi-dev libharfbuzz-dev libjansson-dev liblzma-dev libmp3lame-dev libogg-dev libopus-dev libsamplerate-dev libspeex-dev libtheora-dev libtool libtool-bin libvorbis-dev libx264-dev libxml2-dev m4 make patch pkg-config python tar yasm zlib1g-dev libvpx-dev xz-utils bzip2 zlib1g meson libnuma-dev

wget https://github.com/HandBrake/HandBrake/releases/download/1.6.1/HandBrake-1.6.1-source.tar.bz2

tar -xf HandBrake-1.6.1-source.tar.bz2

cd HandBrake-1.6.1/

echo "X265_8.CONFIGURE.extra += -DENABLE_ASSEMBLY=OFF -DENABLE_PIC=ON -DENABLE_AGGRESSIVE_CHECKS=ON -DENABLE_TESTS=ON -DCMAKE_SKIP_RPATH=ON" >> ./contrib/x265_8bit/module.defs && echo "X265_10.CONFIGURE.extra += -DENABLE_ASSEMBLY=OFF -DENABLE_PIC=ON -DENABLE_AGGRESSIVE_CHECKS=ON -DENABLE_TESTS=ON -DCMAKE_SKIP_RPATH=ON" >> ./contrib/x265_10bit/module.defs && echo "X265_12.CONFIGURE.extra += -DENABLE_ASSEMBLY=OFF -DENABLE_PIC=ON -DENABLE_AGGRESSIVE_CHECKS=ON -DENABLE_TESTS=ON -DCMAKE_SKIP_RPATH=ON" >> ./contrib/x265_12bit/module.defs && echo "X265.CONFIGURE.extra += -DENABLE_ASSEMBLY=OFF -DENABLE_PIC=ON -DENABLE_AGGRESSIVE_CHECKS=ON -DENABLE_TESTS=ON -DCMAKE_SKIP_RPATH=ON" >> ./contrib/x265/module.defs

./configure --launch-jobs=$(nproc) --disable-gtk --disable-nvenc --disable-qsv --enable-fdk-aac

cd build/

make -j $(nproc) (wait for downloads to finish and interrupt)

nano ./contrib/x265/x265-snapshot-20221130-12747/source/common/primitives.cpp

Modify the file to look like this (change == to !=)

tail -6 ./contrib/x265/x265_3.2.1/source/common/primitives.cpp

if X265_ARCH_ARM != 0

void PFX(cpu_neon_test)(void) {} int PFX(cpu_fast_neon_mrc_test)(void) { return 0; }

endif // X265_ARCH_ARM

}

endif

make clean

make -j $(nproc) sudo make install