Polochon-street / blissify-rs

bliss bindings for MPD.
30 stars 6 forks source link

Compiling on Raspberry Pi #16

Closed Kriegbaum closed 10 months ago

Kriegbaum commented 3 years ago

Hi! I'm trying to get this up and running on a raspberry pi as the title suggests. I've gone through a lot of dependencies, and at this point I've hit two issues with compiling. One I could fix and one I could not.

error[E0308]: mismatched types --> /home/pi/.cargo/registry/src/github.com-1285ae84e5963aae/ffmpeg-next-4.4.0/src/util/error.rs:205:7 205 [[0_i8; AV_ERROR_MAX_STRING_SIZE]; 27]; ^^^^ expected u8, found i8

help: change the type of the numeric literal from i8 to u8 | 205 | [[0_u8; AV_ERROR_MAX_STRING_SIZE]; 27]; | ^^^^

error: aborting due to previous error

For more information about this error, try rustc --explain E0308. error: failed to compile blissify v0.2.2, intermediate artifacts can be found at /tmp/cargo-installmbmEs8

Caused by: could not compile ffmpeg-next

To learn more, run the command again with --verbose.

Taking the compiler's suggestion of changing i8 to u8 cleared that one

now I've hit this:

error[E0004]: non-exhaustive patterns: AV_PIX_FMT_SAND64_16, AV_PIX_FMT_RPI4_8 and AV_PIX_FMT_RPI4_10 not covered --> /home/pi/.cargo/registry/src/github.com-1285ae84e5963aae/ffmpeg-next-4.4.0/src/util/format/pixel.rs:413:15 413 match value { ^^^^^ patterns AV_PIX_FMT_SAND64_16, AV_PIX_FMT_RPI4_8 and AV_PIX_FMT_RPI4_10 not covered
::: /tmp/cargo-installN6hIRT/release/build/ffmpeg-sys-next-85cb1efc39cad5e2/out/bindings.rs:5653:5
 |
5653 AV_PIX_FMT_SAND64_16 = 190, -------------------- not covered 5654 AV_PIX_FMT_RPI4_8 = 191, ----------------- not covered 5655 AV_PIX_FMT_RPI4_10 = 192, ------------------ not covered
 = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms
 = note: the matched value is of type `sys::AVPixelFormat`

error: aborting due to previous error

For more information about this error, try rustc --explain E0004. error: failed to compile blissify v0.2.2, intermediate artifacts can be found at /tmp/cargo-installN6hIRT/

Caused by: could not compile ffmpeg-next

Any idea where to look to fix this?

Polochon-street commented 3 years ago

Hi, It seems that these AVPixelFomat are specific for ffmpeg on rasperry pi (https://github.com/shantigilbert/Embylogic/blob/master/packages/multimedia/ffmpeg/patches/rpi4-hevc/ffmpeg-001-pfcd_hevc_optimisations.patch here apparently). Does it work if you change the pixel.rs file and add the values in the enum, a bit like this PR does https://github.com/zmwangx/rust-ffmpeg/pull/60/files#diff-f9150192df441c0071988ac35697c7739854b75cbbd46bc884a36394830b7874R102 ?

On a side-note, bliss' analysis is pretty heavy on the CPU, so depending on the number of songs you have in your library, you might want to analyze them on a tougher CPU, then transfer ~/.local/share/bliss-rs/songs.db to your raspberry pi and use blissify without analyzing everything again. (though the song's paths must match)

Kriegbaum commented 3 years ago

I got it! Looks like there was an 'rpi' compile flag that needed to be set somewhere. I've done a little bit of rust coding but its been a while since I've touched the environments so I just removed the check haha. Definitely not pretty but got me the binary I was looking for. Analyzing 11799 songs, this might take some time… We shall see how the RPI handles this

Kriegbaum commented 3 years ago

Surprisingly, MPD and Snapcast can run uninterrupted in the background while this churns away! Those services often lock and stutter when I'm doing heavy lifting with this little machine

Polochon-street commented 3 years ago

Hi, I've taken a deeper look, and turns out there's actually a flag for compiling ffmpeg on raspberry pis, as you said :smile:

I've made some adjustments so you can actually use it while installing blissify - it should be as simple as running cargo install blissify --features=ffmpeg-next/rpi.

Hope that works for you!

Polochon-street commented 2 years ago

closing this - feel free to reopen if your issue hasn't been solved :)

kbridger commented 1 year ago

I'm hitting the same problem while trying to compile on an rpi. Same error E0004.

Your workaround doesn't seem to be working either. Anything else I can try out?

pi@cookie:~/.cargo/bin $ cargo install blissify --features=ffmpeg-next/rpi Updating crates.io index Installing blissify v0.3.5 error: failed to compile blissify v0.3.5, intermediate artifacts can be found at /tmp/cargo-installOS5GmL

Caused by: none of the selected packages contains these features: ffmpeg-next/rpi

Polochon-street commented 1 year ago

Hi, thanks for reporting :)

I updated bliss / blissify, and you should now be able to do cargo install blissify --features=bliss-audio/rpi. Hope that fixes it!

Phil-BKK commented 1 year ago

Hi, I am very much looking forward to using this however am running into problems compiling on my RPi4. Error data from build below:

error[E0425]: cannot find value AV_PIX_FMT_RPI in this scope --> /home/pi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-next-6.0.0/src/util/format/pixel.rs:1213:27 1213 Pixel::RPI => AV_PIX_FMT_RPI, ^^^^^^^^^^^^^^ help: a unit variant with a similar name exists: AV_PIX_FMT_0RGB

::: /tmp/cargo-installPWnJQZ/release/build/ffmpeg-sys-next-720654b8f40ecd85/out/bindings.rs:5730:5 | 5730 | AV_PIX_FMT_0RGB = 120, | --------------- similarly named unit variant AV_PIX_FMT_0RGB defined here

Can anyone assist to resolve ?

Thanks in advance

altesockensuppe commented 11 months ago

Hi

$ cargo install --features=ffmpeg-next/rpi
error: none of the selected packages contains these features: ffmpeg-next/rpi

so that I could install blissify-rs I had to add ffmpeg-next with the command cargo add ffmpeg-next.
After that everything worked as desired.

Best AlteSocke

Polochon-street commented 11 months ago

Hi,

I've just updated some of blissify's dependencies - does cargo install blissify --features=bliss-audio/rpi work out of the box? I don't have a raspberry pi, so I can't test myself, but it should work 🤞

altesockensuppe commented 11 months ago

Hi @Polochon-street

sadly it fails on ffmpeg-next

Here the procedure on a fresh raspi 3 debian bullseye

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source "$HOME/.cargo/env"
apt install -y clang libavcodec-dev libavformat-dev libavutil-dev pkg-config
cargo install blissify --features=bliss-audio/rpi
    failed because of missing `libavfilter`
apt install libavfilter-dev
cargo install blissify --features=bliss-audio/rpi
   failed because of missing `libavdevice`
apt install libavdevice-dev
cargo install blissify --features=bliss-audio/rpi
    failed because of missing `ffmpeg-next`

cargo error output

[...]
   Compiling tempdir v0.3.7
   Compiling ndarray-stats v0.5.1
error[E0425]: cannot find value `AV_PIX_FMT_RPI` in this scope
    --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-next-6.1.0/src/util/format/pixel.rs:1252:27
     |
1252 |             Pixel::RPI => AV_PIX_FMT_RPI,
     |                           ^^^^^^^^^^^^^^ help: a unit variant with a similar name exists: `AV_PIX_FMT_0RGB`
     |
    ::: /tmp/cargo-installm5PIL6/release/build/ffmpeg-sys-next-86a89553036e5246/out/bindings.rs:3:174597
     |
3    | ...MT_CUDA = 119 , AV_PIX_FMT_0RGB = 120 , AV_PIX_FMT_RGB0 = 121 , AV_PIX_FMT_0BGR = 122 , AV_PIX_FMT_BGR0 = 1...
     |                    --------------- similarly named unit variant `AV_PIX_FMT_0RGB` defined here

For more information about this error, try `rustc --explain E0425`.
error: could not compile `ffmpeg-next` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `blissify v0.3.7`, intermediate artifacts can be found at `/tmp/cargo-installm5PIL6`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

try a other way...

git clone https://github.com/Polochon-street/blissify-rs.git
cd blissify-rs
~/.cargo/bin/cargo build --features=bliss-audio/rpi
    error: could not compile `ffmpeg-next` (lib) due to previous error

~/.cargo/bin/cargo add ffmpeg-next
~/.cargo/bin/cargo build --features=bliss-audio/rpi
    same error:
[...]
   Compiling rcue v0.1.3
   Compiling humantime v2.1.0
error[E0425]: cannot find value `AV_PIX_FMT_RPI` in this scope
    --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-next-6.1.0/src/util/format/pixel.rs:1252:27
     |
1252 |             Pixel::RPI => AV_PIX_FMT_RPI,
     |                           ^^^^^^^^^^^^^^ help: a unit variant with a similar name exists: `AV_PIX_FMT_0RGB`
     |
    ::: /root/blissify-rs/target/debug/build/ffmpeg-sys-next-a3e9d3125c441cbb/out/bindings.rs:3:174597
     |
3    | ...MT_CUDA = 119 , AV_PIX_FMT_0RGB = 120 , AV_PIX_FMT_RGB0 = 121 , AV_PIX_FMT_0BGR = 122 , AV_PIX_FMT_BGR0 = 1...
     |                    --------------- similarly named unit variant `AV_PIX_FMT_0RGB` defined here
[...]
error: could not compile `ffmpeg-next` (lib) due to previous error

~/.cargo/bin/cargo clean
~/.cargo/bin/cargo build --features=bliss-audio/rpi --features=ffmpeg-next/rpi
    same `ffmpeg-next` error

~.cargo/bin/cargo install blissify --features=bliss-audio/rpi --features=ffmpeg-next/rpi
    again a `ffmpeg-next` error
error: failed to compile `blissify v0.3.7`, intermediate artifacts can be found at `/tmp/cargo-installSYrFS6`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Caused by:
  none of the selected packages contains these features: ffmpeg-next/rpi

Best AlteSocke

Phil-BKK commented 11 months ago

Greetings!

There is a ticket open against rust-ffmpeg related to this:

115 - Handle unsupported pixel formats properly

https://github.com/zmwangx/rust-ffmpeg/pull/114

Cheers

Phil...

Polochon-street commented 11 months ago

Hi,

Thanks for the heads-up. I managed to find a Raspberry Pi 4B and try it out, and it seems that doing cargo install blissify (without the feature) works - I could do blissify init and blissify playlist just fine.

Could you try it out? Otherwise I'll see what I can do to reproduce.

Phil-BKK commented 10 months ago

Hi Polochon-streeet

I still experience failure using 'cargo install blissify'

Error log as follows:

error[E0004]: non-exhaustive patterns: sys::AVPixelFormat::AV_PIX_FMT_SAND128, sys::AVPixelFormat::AV_PIX_FMT_SAND64_10, sys::AVPixelFormat::AV_PIX_FMT_SAND64_16 and 2 more not covered --> /home/pevans68/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ffmpeg-next-6.1.0/src/util/format/pixel.rs:480:15 480 match value { ^^^^^ patterns sys::AVPixelFormat::AV_PIX_FMT_SAND128, sys::AVPixelFormat::AV_PIX_FMT_SAND64_10, sys::AVPixelFormat::AV_PIX_FMT_SAND64_16 and 2 more not covered
note: sys::AVPixelFormat defined here --> /tmp/cargo-installdmpFsK/release/build/ffmpeg-sys-next-224e96039c8ada5c/out/bindings.rs:5608:1 5608 pub enum AVPixelFormat { ^^^^^^^^^^^^^^^^^^^^^^ = note: the matched value is of type sys::AVPixelFormat help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms

751 ~ AV_PIX_FMTY210LE => Pixel::Y210LE, 752 ~ => todo!(),

Regards

Phil...

altesockensuppe commented 10 months ago

@Polochon-street I tested it with a Raspberry 3b. @Phil-BKK I had the same error while I test on Rapberry 5!

Phil-BKK commented 10 months ago

Hi

Running RPiOS 11 Bullseye. double loaded with Moode & Plexamp

Phil...

Polochon-street commented 10 months ago

There was some issue on the rust-ffmpeg side, but it should be fixed now - I managed to reproduce and fix on a rasperry pi. Could you try to build the version 0.3.8 of the crate (the latest)? I bumped rust-ffmpeg, bliss and blissify, so it should be all good.

It does depend how ffmpeg was compiled for your raspberry pi, if ffmpeg -version|grep rpi yields a line with --enable-rpi, then you need the --features=rpi, otherwise you shouldn't use it (if you use it and ffmpeg hasn't been compiled with rpi support, it'll not build properly).

Hopefully it'll work now! 🤞

Phil-BKK commented 10 months ago

Hi Polochon-street

It has now built okay. A couple of observations:

checking ffmpeg version for rpi features netted no result, however build still failed enabling '--features=rpi' allowed the compile progress untill almost complete, then failed on ' cannot find -lsqlite3' installing sqlite via sudo apt-get install libsqlite3-dev and compile completed fully

thanks for your assistannce and perserverence

regards

Phil...

altesockensuppe commented 10 months ago

Hi @Polochon-street

I can confirm that it works on Raspberry Pi 5 with command: carogo install blissify --features=rpi

It is also possible to read out and update the database.

Thank you very much!

Best
AlteSocke

Polochon-street commented 10 months ago

Awesome! Thank you guys for your patience, I also completed the README with the proper dependencies. Cheers!

chourmovs commented 4 months ago

Hi On rpi 4 running volumio latest beta

cargo install --features=rpi blissify

error[E0004]: non-exhaustive patterns: `sys::AVPixelFormat::AV_PIX_FMT_RPI` not covered
    --> /home/volumio/.cargo/registry/src/index.crates.io-1cd66030c949c28d/ffmpeg-next-.0.2/src/util/format/pixel.rs:481:15

481  match value { ^^^^^ pattern `sys::AVPixelFormat::AV_PIX_FMT_RPI` not covered
note: `sys::AVPixelFormat` defined here
    --> /tmp/cargo-installFVYmjS/release/build/ffmpeg-sys-next-b525e8aeeb6cefc5/out/bindings.rs:5478:15478 | pub enum AVPixelFormat { 5600 |     AV_PIX_FMT_RPI = 120,    -------------- not covered
     = note: the matched value is of type `sys::AVPixelFormat`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown

838  ~             AV_PIX_FMT_RPI4_10 => Pixel::RPI4_10,
839  ~             sys::AVPixelFormat::AV_PIX_FMT_RPI => todo!(),

   Compiling extended-isolation-forest v0.2.3
   Compiling indicatif v0.17.8
For more information about this error, try `rustc --explain E0004`.error: could not compile `ffmpeg-next` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `blissify v0.4.1`, intermediate artifacts can be found at `/tmp/cargo-installFVYmjS`.
To reuse those artifacts with a future compilation, set the environment variable  
wheaten commented 4 months ago

Model : Raspberry Pi 4 Model B Rev 1.2 Linux volumio 6.1.69-v7l+ armv7l GNU/Linux

As follow-up on what chourmovs mentioned. Tried with: cargo install blissify --features=ffmpeg-next/rpi cargo install blissify --features=bliss-audio/rpi

The latter brought me the farst, however the it errored out on a certain error in a ffmpeg folder in error.rs. Mentioned i8 and it should be u8. Modified it but then errored out on the next error, can't recall the exact error. Finally gave up after 3 hours.

Polochon-street commented 4 months ago

Hi,

Thank you for reporting :)

Could I get the output of ffmpeg -version? Trying to figure out which version you guys are using

wheaten commented 4 months ago

volumio@rpi4-argon:~$ ffmpeg -version ffmpeg version 4.1.11-0+deb10u1+rpt1 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 8 (Raspbian 8.3.0-6+rpi1) configuration: --prefix=/usr --extra-version=0+deb10u1+rpt1 --toolchain=hardened --incdir=/usr/include/arm-linux-gnueabihf --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-omx-rpi --enable-mmal --enable-neon --enable-rpi --enable-vout-drm --enable-v4l2-request --enable-libudev --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --libdir=/usr/lib/arm-linux-gnueabihf --cpu=arm1176jzf-s --arch=arm libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100

Polochon-street commented 4 months ago

This is an old(er) ffmpeg version, is it possible for you to update it?

If not, the way to go would be to try and fix the output of cargo install --features=rpi blissify. What happens if you go to /home/volumio/.cargo/registry/src/index.crates.io-1cd66030c949c28d/ffmpeg-next-.0.2/src/util/format/pixel.rs, and change add the suggested line sys::AVPixelFormat::AV_PIX_FMT_RPI => todo!(),?

Wondering if it will compile then.

chourmovs commented 4 months ago

@Polochon-street more context for your info : https://community.volumio.com/t/smartqueue-plugin/67801

wheaten commented 4 months ago

Can't update any seeded part of Volumio, as this will break OTA. It';s still a music player :-) Added: image

Compiled successful with 1 warning:

    Finished `release` profile [optimized] target(s) in 7m 23s
warning: the following packages contain code that will be rejected by a future version of Rust: mpd v0.0.12
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
  Installing /home/volumio/.cargo/bin/blissify
   Installed package `blissify v0.4.1` (executable `blissify`)
wheaten commented 4 months ago

Same problems for the CM4. Added: image

Polochon-street commented 4 months ago

After skimming through the context link you provided, is a successful build (like those above) enough for you guys? It looks like that version of ffmpeg is not an official version, but specific to volumio / the raspberry pi, so I don't think it could make it to the main rust-ffmpeg repo (at least I couldn't find any traces of e.g. AV_PIX_FMT_RPI in the official ffmpeg repo or on google)

chourmovs commented 4 months ago

Hi Polochon, Yes today I've in hand several versions successfully build on different host/arch by wheaten or I, certain after having manually altered /home/volumio/.cargo/registry/src/index.crates.io-1cd66030c949c28d/ffmpeg-next-.0.2/src/util/format/pixel.rs (for RPI)

I've also crosscompiled a RPI version from source from my non RPI ARMV7l host (tinkerboard running volumio) using

rustup target add armv7-unknown-linux-gnueabihf
cargo build --target=armv7-unknown-linux-gnueabihf --release

that work on RPI 4/5 apparently without --features=rpi blissify, any file alteration or whatever ...

based on this success, I now try to make a github workflow to build every arch, RPI and not RPI, but I don't succeed for the moment