OpenVisualCloud / SVT-VP9

SVT VP9 encoder. Scalable Video Technology (SVT) is a software-based video coding technology that is highly optimized for Intel® Xeon® processors. Using the open source SVT-VP9 encoder, it is possible to spread video encoding processing across multiple Intel® Xeon® processors to achieve a real advantage of processing efficiency.
Other
221 stars 48 forks source link

FFMPEG patch fails when combined with AV1 & HEVC #97

Closed alatteri closed 4 years ago

alatteri commented 4 years ago

Hello,

Building on Ubuntu 19.10. After compiling SVT-HEVC/AV1/VP9. I go to apply all 3 patches per instructions, VP9 fails.

administrator@colorstreamS02:~/ffmpeg_sources$ git clone https://github.com/FFmpeg/FFmpeg ffmpeg
Cloning into 'ffmpeg'...
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 589146 (delta 4), reused 3 (delta 2), pack-reused 589138
Receiving objects: 100% (589146/589146), 229.34 MiB | 26.76 MiB/s, done.
Resolving deltas: 100% (461076/461076), done.
administrator@colorstreamS02:~/ffmpeg_sources$ cd ffmpeg
administrator@colorstreamS02:~/ffmpeg_sources/ffmpeg$ git checkout -b tag4.2.2 n4.2.2
Switched to a new branch 'tag4.2.2'
administrator@colorstreamS02:~/ffmpeg_sources/ffmpeg$ export LD_LIBRARY_PATH+=":/usr/local/lib"
administrator@colorstreamS02:~/ffmpeg_sources/ffmpeg$ export PKG_CONFIG_PATH+=":/usr/local/lib/pkgconfig"
administrator@colorstreamS02:~/ffmpeg_sources/ffmpeg$ git apply ../SVT-HEVC/ffmpeg_plugin/0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch
administrator@colorstreamS02:~/ffmpeg_sources/ffmpeg$ git apply ../SVT-AV1/ffmpeg_plugin/0001-Add-ability-for-ffmpeg-to-run-svt-av1-with-svt-hevc.patch
administrator@colorstreamS02:~/ffmpeg_sources/ffmpeg$ git apply ../SVT-VP9/ffmpeg_plugin/0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch
error: patch failed: configure:264
error: configure: patch does not apply
error: patch failed: libavcodec/Makefile:991
error: libavcodec/Makefile: patch does not apply
error: patch failed: libavcodec/allcodecs.c:707
error: libavcodec/allcodecs.c: patch does not apply
administrator@colorstreamS02:~/ffmpeg_sources/ffmpeg$ PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
administrator@colorstreamS02:~/ffmpeg_sources/ffmpeg$ ./configure --enable-gpl --enable-libaom --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree --enable-libsvtav1 --enable-libsvtvp9  --enable-libsvthevc
Unknown option "--enable-libsvtvp9".
See ./configure --help for available options.
1480c1 commented 4 years ago

Use https://github.com/OpenVisualCloud/SVT-VP9/blob/master/ffmpeg_plugin/0001-Add-ability-for-ffmpeg-to-run-svt-vp9-with-hevc-av1.patch instead

SolarAquarion commented 4 years ago

the patch needs to be rebased i think

applying the patch on the ffmpeg

1 out of 4 hunks FAILED -- saving rejects to file configure.rej

1480c1 commented 4 years ago

You can use the patches from https://gist.github.com/1480c1/ecc1dd3a15093398492c86f2314f4a67

I rebased them and made them atomic so there's no order you need to follow. I am planning to update them whenever the FFmpeg patches get touched

mash-graz commented 4 years ago

@1480c1 unfortunatly this also doesn't work sufficient.

if i apply only you patch, --enable-libsvthevc isn't available, and when i add the two other patches as used in the common OVC ffmpeg Dockerfiles, the patch stumbles over already existing content. :(

1480c1 commented 4 years ago

Did you make sure to apply the svt hevc patch in the gist? There's three total patches in it

mash-graz commented 4 years ago

i just pipped the the raw data representation by help of curl into | patch -p1

mash-graz commented 4 years ago

ok... now i got it! :) ... i'll try to compile it again... thanks!

mash-graz commented 4 years ago

@1480c1

hmm... the second patch unfortunately doesn't work anymore:

Step 27/33 : RUN cd /home/FFmpeg;     curl -L https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/e018e943eee6675fe1ddb88eb07059066bff63cd/0001-Add-ability-for-ffmpeg-to-run-svt-av1.patch     | patch -p1     && curl -L https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/e018e943eee6675fe1ddb88eb07059066bff63cd/0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch     | patch -p1     && curl -L https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/e018e943eee6675fe1ddb88eb07059066bff63cd/0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch     | patch -p1
 ---> Running in 61b8fe558ff8
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22881  100 22881    0     0   360k      0 --:--:-- --:--:-- --:--:--  360k
patching file configure
Hunk #2 succeeded at 1756 (offset -5 lines).
Hunk #3 succeeded at 3154 (offset -37 lines).
Hunk #4 succeeded at 6186 (offset -83 lines).
patching file libavcodec/Makefile
Hunk #1 succeeded at 961 (offset -21 lines).
patching file libavcodec/allcodecs.c
Hunk #1 succeeded at 681 with fuzz 2 (offset -14 lines).
patching file libavcodec/libsvt_av1.c
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 17169  100 17169    0     0   284k      0 --:--:-- --:--:-- --:--:--  289k
patching file configure
Hunk #1 succeeded at 279 (offset -2 lines).
Hunk #2 succeeded at 1803 (offset -6 lines).
Hunk #3 succeeded at 3206 (offset -36 lines).
Hunk #4 succeeded at 6306 (offset -86 lines).
patching file libavcodec/Makefile
Hunk #1 succeeded at 1002 (offset -21 lines).
patching file libavcodec/allcodecs.c
Hunk #1 succeeded at 717 (offset -14 lines).
patching file libavcodec/avcodec.h
Hunk #1 succeeded at 708 with fuzz 2 (offset 176 lines).
patching file libavformat/dashenc.c
Hunk #1 succeeded at 1823 (offset -443 lines).
Hunk #2 succeeded at 1912 (offset -443 lines).
Hunk #3 succeeded at 1989 (offset -456 lines).
patching file libavformat/ivfenc.c
Hunk #2 succeeded at 119 (offset -2 lines).
patching file libavformat/matroskaenc.c
Hunk #1 FAILED at 152.
Hunk #2 FAILED at 2080.
Hunk #3 FAILED at 2258.
Hunk #4 FAILED at 2269.
Hunk #5 succeeded at 2401 with fuzz 2 (offset 117 lines).
Hunk #6 FAILED at 2306.
Hunk #7 FAILED at 2370.
Hunk #8 FAILED at 2394.
Hunk #9 succeeded at 2741 (offset 32 lines).
7 out of 9 hunks FAILED -- saving rejects to file libavformat/matroskaenc.c.rej
patching file libavformat/movenc.c
Hunk #1 FAILED at 5818.
Hunk #2 succeeded at 6758 (offset -218 lines).
1 out of 2 hunks FAILED -- saving rejects to file libavformat/movenc.c.rej
The command '/bin/sh -c cd /home/FFmpeg;     curl -L https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/e018e943eee6675fe1ddb88eb07059066bff63cd/0001-Add-ability-for-ffmpeg-to-run-svt-av1.patch     | patch -p1     && curl -L https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/e018e943eee6675fe1ddb88eb07059066bff63cd/0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch     | patch -p1     && curl -L https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/e018e943eee6675fe1ddb88eb07059066bff63cd/0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch     | patch -p1' returned a non-zero code: 1
tianjunwork commented 4 years ago

0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch 0001-Add-ability-for-ffmpeg-to-run-svt-av1-with-svt-hevc.patch 0001-Add-ability-for-ffmpeg-to-run-svt-vp9-with-hevc-av1.patch Please apply these three one by one.

mash-graz commented 4 years ago

@tianjunwork if you are referring to the three parts in the gist from @1480c1, than i already applied them individually, as you can see in the quote of my last message.

but the order is a different in your suggestion... that's easy to change and try. i just used the actual order in the gist until now...

1480c1 commented 4 years ago

I will check again if SVT-VP9 master branch patch no longer works again

1480c1 commented 4 years ago

@mash-graz, can you try

curl -L "https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/0001-Add-ability-for-ffmpeg-to-run-svt-av1.patch" "https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch" "https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch" | git am

On the current FFmpeg master branch, (2b32068916)

ccom1@sv-kuri1:/code/FFmpeg$ curl -L "https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/0001-Add-ability-for-ffmpeg-to-run-svt-av1.patch" "https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/0001-Add-ability-for-ffmpeg-to-run-svt-vp9.patch" "https://gist.githubusercontent.com/1480c1/ecc1dd3a15093398492c86f2314f4a67/raw/0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch" | git am
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22881  100 22881    0     0  99051      0 --:--:-- --:--:-- --:--:-- 99051
100 17169  100 17169    0     0   986k      0 --:--:-- --:--:-- --:--:--  986k
100 24216  100 24216    0     0  1313k      0 --:--:-- --:--:-- --:--:-- 1313k
Applying: Add ability for ffmpeg to run svt-av1
Applying: Add ability for ffmpeg to run svt vp9
Applying: lavc/svt_hevc: add libsvt hevc encoder wrapper
mash-graz commented 4 years ago

@1480c1 sure! -- and thank's for all your efforts!

btw: thanks to @tianjunwork -- in the meanwhile i tested this alternative order as well, but unfortunatly it doesn't solve the issue... but nevertheless: thanks! :)

1480c1 commented 4 years ago

Oh wait, before that @mash-graz what branch/tag of FFmpeg are you on?

mash-graz commented 4 years ago

i can take whatever you like!

but i personally would prefer a more recent git version, because the older official releases (at least till 4.2.2) are plagued by an ugly bug, whenever you use multiple filters in complex -map contexts, as it is necessary for DASH/HLS creation resp. different image scaling... but that's a minor issue, which i can workaround by other means resp. additional patching as well.

1480c1 commented 4 years ago

The patches I have in the gist are based on the master branch, the patches in this repo are based on the n4.2.2 tag, if you are going to use the patches here and in the other SVT repos, you will need to use n4.2.2, else you can use the master branch with the patches in the gist

mash-graz commented 4 years ago

@1480c1 i'll simply try your gist on ffmpeg master... if it works, it would fulfill all my needs...

mash-graz commented 4 years ago

@1480c1 there are still troubles... :(

at the ffmpeg linker stage i get the error:

gcc: error: libavcodec/libsvt_vp9.o: No such file or directory
ar: libavcodec/libsvt_vp9.o: No such file or directory

and while looking around, i saw, that there is no libsvt_vp9.c at all in the libavcodec dir:

root@b6269cd52b68:/home# find . -name libsvt*
./FFmpeg/libavcodec/libsvt_av1.c
./FFmpeg/libavcodec/libsvt_hevc.c

in your patches i also couldn't find any generating diff for this particular source...

did i miss any necessary additional step?

1480c1 commented 4 years ago

Try again, I regenerated the patch, it seems git missed the file when I rebased

mash-graz commented 4 years ago

thanks!!! this time it worked! :) i'll try to test it and make a interim image available, if everything works as expected.

mash-graz commented 4 years ago

if anyone needs access to my debian testing and ffmpeg git master branch based docker image, which provides all three SVT ffmpeg plugins, you can pull it from this public docker repository:

registry.gitlab.com/mash-graz/ffmpeg-svt

the used Dockerfile resp. build environment is also available in the corresponding git repo:

https://gitlab.com/mash-graz/ffmpeg-svt

but i also have to report, that the VP9 plugin seems to work fine under moderate system load, but behaves very unreliable and buggy under high pressure. on my test-setup, where i transcode h.264, h.265, vp9 and av1 in parallel in 6 different image resolutions, the encoding process always freezes after a few seconds, when i utilize the libsvt_vp9 plugin instead of libvpx_vp9. libsvt_av1 in contrast works fine under the same conditions. i'll later report this particular flaw in another issue ticket in more detail.

tianjunwork commented 4 years ago

Thank you @mash-graz for sharing the docker image. Yes, please let us know what issue you encounter with svt-vp9.