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

AV1 encoder and decoder #9

Closed
Aleksid1 opened this issue Jul 2, 2024 · 15 comments · Fixed by #11
Closed

AV1 encoder and decoder #9

Aleksid1 opened this issue Jul 2, 2024 · 15 comments · Fixed by #11
Assignees
Labels
enhancement New feature or request

Comments

@Aleksid1
Copy link

Aleksid1 commented Jul 2, 2024

Hi,
Please can you add example for downloading/compiling dav1d and libsvtav1 libs?

@barndawgie barndawgie added the enhancement New feature or request label Jul 2, 2024
@barndawgie barndawgie self-assigned this Jul 2, 2024
@barndawgie
Copy link
Owner

Will try to take a look but it might be a couple of weeks.

@Aleksid1
Copy link
Author

Aleksid1 commented Jul 2, 2024

I would be very grateful to you!
There is another simple FFmpeg script, but it only compiles for Mac and Linux:
https://github.com/markus-perl/ffmpeg-build-script
It includes support for dav1d and libsvtav1 libs.
If it possible, please add examples for Intel QSV and AMD AMF encoders.

@barndawgie
Copy link
Owner

libdav1d was pretty easy. Check out: #11

    do_git_checkout $dav1d_git $dav1d_version dav1d
    pushd dav1d || exit
    meson setup build --cross-file=package/crossfiles/x86_64-w64-mingw32.meson --default-library=static --prefix=$prefix
    cd ./build || exit
    ninja
    ninja install
    popd || exit

libsvtav1 looks more complicated as there isn't cross-compile documentation and it has some undeclared dependencies; I will see if I can figure it out.

@Aleksid1
Copy link
Author

Aleksid1 commented Jul 9, 2024

I'll check dav1d today later. Thanks!
I saw libsvtav1 support in another script for Mac/Linux:
https://github.com/markus-perl/ffmpeg-build-script/blob/master/build-ffmpeg

if build "svtav1" "2.0.0"; then
  # Last known working commit which passed CI Tests from HEAD branch
  download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v$CURRENT_PACKAGE_VERSION/SVT-AV1-v$CURRENT_PACKAGE_VERSION.tar.gz" "svtav1-$CURRENT_PACKAGE_VERSION.tar.gz"
  cd "${PACKAGES}"/svtav1-$CURRENT_PACKAGE_VERSION//Build/linux || exit
  execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
  execute make -j $MJOBS
  execute make install
  execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/"
  execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/"
  build_done "svtav1" $CURRENT_PACKAGE_VERSION
fi
CONFIGURE_OPTIONS+=("--enable-libsvtav1")

@barndawgie
Copy link
Owner

I'll check dav1d today later. Thanks!

I saw libsvtav1 support in another script for Mac/Linux:

https://github.com/markus-perl/ffmpeg-build-script/blob/master/build-ffmpeg


if build "svtav1" "2.0.0"; then

  # Last known working commit which passed CI Tests from HEAD branch

  download "https://gitlab.com/AOMediaCodec/SVT-AV1/-/archive/v$CURRENT_PACKAGE_VERSION/SVT-AV1-v$CURRENT_PACKAGE_VERSION.tar.gz" "svtav1-$CURRENT_PACKAGE_VERSION.tar.gz"

  cd "${PACKAGES}"/svtav1-$CURRENT_PACKAGE_VERSION//Build/linux || exit

  execute cmake -DCMAKE_INSTALL_PREFIX="${WORKSPACE}" -DENABLE_SHARED=off -DBUILD_SHARED_LIBS=OFF ../.. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release

  execute make -j $MJOBS

  execute make install

  execute cp SvtAv1Enc.pc "${WORKSPACE}/lib/pkgconfig/"

  execute cp SvtAv1Dec.pc "${WORKSPACE}/lib/pkgconfig/"

  build_done "svtav1" $CURRENT_PACKAGE_VERSION

fi

CONFIGURE_OPTIONS+=("--enable-libsvtav1")

This is more or less what I had, but it wouldn't link due to a missing cpuinfo dependency which I need to investigate. Hopefully that can either be disable or added to the script as well.

@Aleksid1
Copy link
Author

Aleksid1 commented Jul 9, 2024

dav1d as AV1 decoder works fine now. Many thanks! Hope that you'll find a solution for libsvtav1

@barndawgie
Copy link
Owner

I think I got libsvtav1 working this morning - will try to get it cleaned up and into the PR this evening.

May I ask what the reason is to prefer libstvav1 vs. libaom?

@Aleksid1
Copy link
Author

Aleksid1 commented Jul 9, 2024

Glad you had success with libsvtav1! I'll wait for the script.
I discovered that libsvtav1 encodes faster than libaom. For libsvtav1 I found many advices regarding options to reach the best AV1 quality.
And dav1d decodes much faster than libaom

@barndawgie
Copy link
Owner

barndawgie commented Jul 10, 2024

Okay, just pushed an update to that PR which I think gets libsvtav1 working. I needed to build cpuinfo as well.

    do_git_checkout $libsvtav1_git $libsvtav1_version libsvtav1
    pushd libsvtav1 || exit
    cd Build/linux || exit
    ./build.sh -t "$config_dir/toolchain-x86_64-w64-mingw32.cmake" -p $prefix --static install
    popd || exit

Just running a full E2E test before I check it in to main.

@Aleksid1
Copy link
Author

Aleksid1 commented Jul 10, 2024

Great! I just checked and libsvtav1 encoder works fine.

@barndawgie
Copy link
Owner

Great! I just checked and libsvtav1 encoder works fine.

There are a lot of build options for it that I didn't look at related to CPU optimizations - I'm hoping the default build is reasonable.

@Aleksid1
Copy link
Author

I'll compare a speed with BtbN FFmpeg build tomorrow.

@Aleksid1
Copy link
Author

Aleksid1 commented Jul 12, 2024

I compared your FFmpeg build with libsvtav1 and BtbN build on Intel CPU 7-gen. Your version encodes slower than BtbN (69s vs 59s). I checked BtbN script for options in libsvtav1:

cmake -DCMAKE_TOOLCHAIN_FILE="$FFBUILD_CMAKE_TOOLCHAIN" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$FFBUILD_PREFIX" -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DBUILD_APPS=OFF -DENABLE_AVX512=ON ..

Probably this option is important: -DENABLE_AVX512=ON

How we can try the same option in your script?

@barndawgie
Copy link
Owner

Very straightforward. #19 adds this, as well as Link Time Optimization. I'm just waiting for the build to succeed before checking it in.

@Aleksid1
Copy link
Author

I'll try it after the weekend. Thank you for your great support and responsiveness!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants