Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffmpeg5 + ffmpeg6 packages #5620

Merged
merged 65 commits into from
Mar 28, 2023
Merged

ffmpeg5 + ffmpeg6 packages #5620

merged 65 commits into from
Mar 28, 2023

Conversation

th0ma7
Copy link
Contributor

@th0ma7 th0ma7 commented Feb 25, 2023

Description

FFMPEG5 Jellyfin optimized package + FFMPEG6 default

Fixes #5085, #5421

Checklist

  • Build rule all-supported completed successfully
  • New installation of package completed successfully
  • Package upgrade completed successfully (Manually install the package again)
  • Package functionality was tested
  • Any needed documentation is updated/created

Type of change

  • Bug fix
  • New Package
  • Package update
  • Includes small framework changes
  • This change requires a documentation update (e.g. Wiki)

@th0ma7 th0ma7 self-assigned this Feb 26, 2023
@th0ma7 th0ma7 mentioned this pull request Feb 26, 2023
10 tasks
@th0ma7 th0ma7 linked an issue Feb 26, 2023 that may be closed by this pull request
1 task
@th0ma7
Copy link
Contributor Author

th0ma7 commented Feb 28, 2023

@hgy59 and @mreid-tt and all, looking for help!

Having issues specifically with x86_64 and i686 builds... I've created an ffmpeg bug issue at https://trac.ffmpeg.org/ticket/10219 with hope to find a solution.

Getting multiple undefined reference to only on those two archs :

LD	ffmpeg_g
LD	ffprobe_g
libavcodec/libavcodec.so: undefined reference to `ff_h264chroma_init_x86'
libavfilter/libavfilter.so: undefined reference to `ff_spp_init_x86'
libavcodec/libavcodec.so: undefined reference to `ff_ttaencdsp_init_x86'
libswresample/libswresample.so: undefined reference to `swri_audio_convert_init_x86'
...

Hints at solving this issue would be much appreciated 🤷

@hgy59
Copy link
Contributor

hgy59 commented Feb 28, 2023

Hints at solving this issue would be much appreciated 🤷

Sometime it helps to force cross compilation for i686 (see cross/erlang/Makefile) - just guessing...

@nyanmisaka
Copy link

nyanmisaka commented Feb 28, 2023

Maybe nasm is too old for the new ffmpeg, which passes the configure check but there's no X86ASM in the ffmpeg5 build logs. Thus all ff_*_x86 asm functions are missing at LD stage. And asm was disabled in ARM builds so those are not affected.

@nyanmisaka
Copy link

Disabling x86 asm can be a stopgap but it causes software decoders and encoders to be extremely slow.

Better to figure out how to re-enable it later. The low-power chips on Synology devices can benefit a lot from this.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Feb 28, 2023

Disabling x86 asm can be a stopgap but it causes software decoders and encoders to be extremely slow.

Better to figure out how to re-enable it later. The low-power chips on Synology devices can benefit a lot from this.

@Nyaran thnx for the pointer. Indeed disabling x86 asm solved the immediate issue. I've updated the ffmpeg track issue to reflect this in hope to get some help.

@th0ma7 th0ma7 changed the title [WIP] ffmpeg5 package [WIP] ffmpeg5 + ffmpeg6 packages Feb 28, 2023
@nyanmisaka
Copy link

I wonder why asm was disabled in arm and ppc?

This is unlikely to be an upstream issue since ffmpeg 5.0 was released more than a year ago.

Maybe --x86asmexe=/path/to/nasm helps.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Feb 28, 2023

I wonder why asm was disabled in arm and ppc?

This pre-date me taking over the maintenance of ffmpeg. I never touched that portion of the build process. Now that this isn't working all right for x86 neither, perhaps it's a good time to review it... similarly, asm is only available for x86 for x265 as well.

Maybe --x86asmexe=/path/to/nasm helps.

I tried that and it didn't worked out neither.

@nyanmisaka
Copy link

NEON asm works for arm processors. Those asm code were written for some DSP and decoders.

https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/arm/Makefile

  --disable-armv5te        disable armv5te optimizations
  --disable-armv6          disable armv6 optimizations
  --disable-armv6t2        disable armv6t2 optimizations
  --disable-vfp            disable VFP optimizations
  --disable-neon           disable NEON optimizations

@th0ma7
Copy link
Contributor Author

th0ma7 commented Mar 1, 2023

@nyanmisaka I've been playing more & more with ASM on various front and really, it works just well for aarch64 but it simply isn't called at all for i686 and x86_64 even though it normally should... w e i r d 🤷

Comment on lines 1 to 3
SPK_NAME = ffmpeg4
SPK_VERS = 4.4.3
SPK_REV = 47
SPK_REV = 48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a good idea. I propose to keep SPK_NAME = ffmpeg
Otherwise this is a new package and you can start with SPK_REV = 1
But then all packages depending on ffmpeg (SPK_DEPENDS = "ffmpeg") will not use further updates (and we will need to keep the latest ffmpeg package in the repository).

SPK_NAME should stay ffmpeg, only DISPLAY_NAME may be changed to ffmpeg4 (or ffmpeg 4).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is more complex than that...

The github build scripts also refers to ffmpeg for it to be pre-process and keept prior to building dependent packages in order to re-use existing libraries. That also needs fixing so a similar behavior is kept for ffmpeg5 and ffmpeg6 which adds complexity as comskip, chromaprint and tvheadend are in various stages of porting over to ffmpeg >= 5.x.

With that in mind, and based on python3 experience, I decided to rename it all to ffmpeg4 along with adjusting dependent packages. Once all dependent packages are migrated over the new naming scheme I'll then be able to start porting them over to a newer ffmpeg. Adding to the blur is jellyfin which requires ffmpeg 5.x for it to run smoothly (and to which there isn't any spk dependencies up until now 🤷 ).

Renaming it all to be ffmpeg<version> is to me the best route as they will have to be maintained in parallel for a while. As for SPK_REV, I can probably switch it to 1 but on the other hand if gives the idea that ffmpeg4 version 48 really is the update from ffmpeg version 47. So I'd rather keeping it as-is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@th0ma7 you can name all folders ffmpeg4 only the SPK_NAME sould stay ffmpeg.
This is similar to the python2 package, where SPK_NAME is still python.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Mar 4, 2023

@hgy59 and @nyanmisaka finally found the build issue... to which we already had a fix for since 4.x era. It hapens that configure script and ffbuild/common.mak uses ARCH variable which in turns gets polluted by spksrc framework usage of ARCH variable... Re-using existing https://github.com/SynoCommunity/spksrc/blob/master/cross/ffmpeg/patches/0001-replace-arch-env-by-ffmpeg_arch.patch solved the matter.

I can now finally move on to next steps 🚀

@nyanmisaka
Copy link

@th0ma7 Nice to hear that. I've seen that patch but didn't understand what it does. We are also updating patches for 6.0 but it's not finalized yet.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Mar 4, 2023

@nyanmisaka if I may recommend, would be nice to keep patches for older ffmpeg releases. I'm still using v4 and now v5 versions of the patches. Pertaining to v6, any insight as of when the patches may be ready? As I'll probably wait for that before releasing it.

@nyanmisaka
Copy link

nyanmisaka commented Mar 5, 2023

@th0ma7 4.4.x is for the old Jellyfin 10.7, it's best to keep the current patches as they are. Downstream only needs to pull the corresponding version of the patch series from the debian/patches folder.

5.1.x will continue to be maintained for a long time since it is LTS and is required by Jellyfin 10.8.

6.x slightly breaks compatibility with Jellyfin 10.8, we will release a new Jellyfin version to adapt it. Before that make the Jellyfin package depend on ffmpeg5.

@nyanmisaka
Copy link

nyanmisaka commented Mar 5, 2023

Just a FYI some FFmpeg options and runtimes used by Jellyfin are not available in spksrc.

Intel Compute-Runtime
https://github.com/intel/compute-runtime
# required by OpenCL tone-mapping on Intel GPU
# build time deps: 
 * libva https://github.com/intel/libva
 * gmmlib https://github.com/intel/gmmlib
 * level-zero https://github.com/oneapi-src/level-zero
 * intel-graphics-compiler https://github.com/intel/intel-graphics-compiler
--enable-opencl
# required by OpenCL tone-mapping on Intel GPU
# build time deps:
 * headers: https://github.com/KhronosGroup/OpenCL-Headers
 * loader: https://github.com/KhronosGroup/OpenCL-ICD-Loader
--enable-libvpl
# [optional] successor of the libmfx, used by FFmpeg 6+
# build time deps: https://github.com/oneapi-src/oneVPL
# run time:
 * UHD6xx and older: libmfxhw64.so* https://github.com/Intel-Media-SDK/MediaSDK
 * UHD7xx, Xe and newer: libmfx-gen.so* https://github.com/oneapi-src/oneVPL-intel-gpu
--enable-ffnvcodec \
--enable-cuda \
--enable-cuda-llvm \
--enable-cuvid \
--enable-nvdec \
--enable-nvenc \
--disable-ptx-compression
# required by hardware transcoding on NVIDIA GPU (jellyfin 10.8 requires n11.0.10.2+)
# build time deps: https://github.com/FFmpeg/nv-codec-headers

@th0ma7
Copy link
Contributor Author

th0ma7 commented Mar 5, 2023

@nyanmisaka thnx for sharing this, that will save me quite a bit of time.

From the get go only a fraction of this will be available to all platforms.

Intel:
I already reached the end of the road for gcc<=4.9.* in regards to intel-media-driver which is a mandatory requirement to intel-media-sdk. Therefore I doubt that level-zero, IGC or oneVPL will ever build for DSM6 but still worth a try. Althought that should be relatively feasible for DSM7+ which uses gcc-7.5 and newer.

nVidia:
I have no clue where to start with... additional pointers or examples would be much appreciated. For instance, does it only need the nv-codec-headers for it to enable ffmpeg build options? Also I see there are other branches available for older driver versions which lead to the need of knowing what version Synology uses in theses case to match things up (I own a few Syno NAS but none using nvidia so can't really test or find out).

@nyanmisaka
Copy link

nyanmisaka commented Mar 5, 2023

Intel: I already reached the end of the road for gcc<=4.9.* in regards to intel-media-driver which is a mandatory requirement to intel-media-sdk. Therefore I doubt that level-zero, IGC or oneVPL will ever build for DSM6 but still worth a try. Althought that should be relatively feasible for DSM7+ which uses gcc-7.5 and newer.

https://gcc.gnu.org/projects/cxx-status.html#cxx14

cpp14 is required by the VPL runtime, which is not fully supported in gcc-4.9 but you can still give it a try.

nVidia: I have no clue where to start with... additional pointers or examples would be much appreciated. For instance, does it only need the nv-codec-headers for it to enable ffmpeg build options? Also I see there are other branches available for older driver versions which lead to the need of knowing what version Synology uses in theses case to match things up (I own a few Syno NAS but none using nvidia so can't really test or find out).

Compiling cuda kernel requires cpp14 too, this part is handled by clang instead of the nvcc that comes with cuda toolkit.

So --enable-cuda-llvm indicates that clang 3.4+ is required https://clang.llvm.org/cxx_status.html

I'm not sure if clang is available in Syno toolchains. You can lower the priority of supporting this as not many people use NVIDIA GPUs on Syno. Other than that you just need to make install the nv-codec-headers header files.

th0ma7 added 4 commits March 19, 2023 13:07
Having a preset conf/resource file makes it that no other
parameters can be set in the resulting file.  This removes the
need of the static file for accessing video-driver by generating
it directly within the normal jq call.
@th0ma7
Copy link
Contributor Author

th0ma7 commented Mar 20, 2023

This should now good for merging. I'll take one last stab at it upon my return and do further testing.

If @hgy59 you can have one last look at it would be nice. My main fear is at filling up our server online...

@nyanmisaka
Copy link

@th0ma7 We updated our patches with some tiny fixes. It'd be great if you can pull the them again before merging.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Mar 20, 2023

@th0ma7 We updated our patches with some tiny fixes. It'd be great if you can pull the them again before merging.

Sure, will do upon my return.

@th0ma7
Copy link
Contributor Author

th0ma7 commented Mar 27, 2023

We updated our patches with some tiny fixes. It'd be great if you can pull the them again before merging.

@nyanmisaka all patches are now updated. Finalizing the testing and should be ready for publishing before end of week.

@th0ma7 th0ma7 merged commit b95f895 into SynoCommunity:master Mar 28, 2023
@th0ma7 th0ma7 deleted the ffmpeg5 branch March 28, 2023 23:09
@hgy59
Copy link
Contributor

hgy59 commented Mar 30, 2023

@th0ma7 there must be something wrong with the changes in the prepare step of the github build action introduced with this PR.

In #5677 I only changed files in native/mono, cross/mono and spk/mono but now it downloads and builds ffmpeg.
https://github.com/SynoCommunity/spksrc/actions/runs/4564982620/jobs/8055461639

@mreid-tt mreid-tt mentioned this pull request Apr 23, 2023
6 tasks
@mreid-tt mreid-tt changed the title [WIP] ffmpeg5 + ffmpeg6 packages ffmpeg5 + ffmpeg6 packages Apr 24, 2023
@th0ma7 th0ma7 mentioned this pull request Dec 29, 2024
6 tasks
AlexPresso pushed a commit to AlexPresso/spksrc that referenced this pull request Jan 30, 2025
* openh264: Import from gstreamer PR SynoCommunity#5298

* twolame: Import from gstreamer PR SynoCommunity#5298

* ffmpeg: Enable openh264 & twolame - import from gstreamer PR SynoCommunity#5298

* ffmpeg4: Rename ffmpeg package to ffmpeg4 (preparation to ffmpeg5)

* ffmpeg: Remove twolame from TODO list

* ffmpeg4: Enable service-setup.sh script only on x64

* ffmpeg4: Miscelanious fixes to get things to build

* github-action: Prepare for ffmpeg5 builds

* ffmpeg5: First tentative build

* Bump package version and changelog

* ffmpeg5: Re-enable svthevc patch

* ffmpeg5: Disable asm optimizations for x86_64 & i686

* ffmpeg6: First tentative basic package

* ffmpeg6: Update PLIST

* nasm: Update from version 2.15.5 to 2.16.1

* libaom: Re-order and allow ASM builds (from cmake-env.mk fix)

* x265: Fix aarch64 ASM build

* ffmpeg4: Re-order ASM code & enable neon optimization for aarch64

* ffmpeg5-6: Re-order ASM code & enable neon optimization for aarch64

* libvpx: Update from version 1.12 to 1.13 and switch to nasm

* libvpx: Disable neon on armv7/7l/8 when using gcc <= 4.9

* x264: Update to latest commit and enable ASM for aarch64

* libvpx: Set nasm to be specific to x86 arch only (x86asm)

* x264: Fix typo

* x264: Add more details about ARM ASM compiling

* libaom: Remove unused comments and trailing blank line

* opus: Fix for comcerto2k-7.1

* ffmpeg: Reorder ASM code and enable on aarch64

* x265: Fix build for comcerto2k-7.1

* ffmpeg6: Fix minor typos

* ffmpeg5-6: Build fix using good old replace ARCH by FFMPEG_ARCH

* ffmpeg4: Re-use ffmpeg5-6 asm makefile code

* tvheadend: Fix FFMPEG_DIR variable

* libva: Update from version 2.16 to version 2.17

* libdrm: Update from version 2.4.114 to 2.4.115

* intel-gmmlib: Update from version 22.3.1 to 22.3.4

* ffmpeg6: Enable SVT-HEVC plugin

* ffmpeg6: Forgot to also include svt-hevc patch for enablement

* dav1d: Update from version 1.0.0 to 1.1.0

* frei0r: Update from version 1.8.0 to 2.2.0

* ffmpeg4: Rename back to ffmpeg & enforce ffmpeg4 directory install

* ffmpeg5-6: Aling DISPLAY_NAME for all ffmpeg versions

* ffmpeg4: Ensure to use ffmpeg4 as cross dependency

* libass: Update from version 0.16.0 to 0.17.1

* SVT-AV1: Update from version 1.3.0 to 1.4.1

* ffmpeg4: Update changelog

* ffmpeg*: Add -lm for svt-av1 and remove redundant frei0r entry

* level-zero: Add version 1.9.4 as ICG dependency

* frei0r: Add cairo as dependency & disable CMAKE_USE_TOOLCHAIN_FILE

* ffmpeg6: Import jellyfin ffmpeg6 patches

* ffmpeg4-5-6: Enable symbolic links in /usr/local/bin

* ffmpeg4-5-6: Fix /usr/local/bin symlink

* service.mk: Add ability to generate json for VIDEODRIVER access

Having a preset conf/resource file makes it that no other
parameters can be set in the resulting file.  This removes the
need of the static file for accessing video-driver by generating
it directly within the normal jq call.

* ffmpeg4-5-6: Misc fixes including symlinks and proper rpath for v4

* github-action: Fix mgmnt of ffmpeg,ffmpeg5,ffmpeg6 dependent spk

* github-action: ffmpeg package is actually spk/ffmpeg4

* ffmpeg5: Update jellyfin patches

* ffmpeg6: Update jellyfin patches

* ffmpeg6: Remove invalid older jellyfin patch

* ffmpeg4: Update howto pertaining to jellyfin patches

* chromaprint+comskip+tvh: Fix ffmpeg dependency version

* tvheadend: Update changelog for updated openssl version

Co-authored-by: hgy59 <hpgy59@gmail.com>

* comskip+chromaprint+tvh: Update SPK_DEPENDS automatically

* svt-av1: Update digests & directory now based on git hash

---------

Co-authored-by: hgy59 <hpgy59@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ffmpeg download not working how to update FFmpeg 5.0
3 participants