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

Build a tiny FFmpeg #385

Open
Aleksid1 opened this issue Jun 19, 2024 · 15 comments
Open

Build a tiny FFmpeg #385

Aleksid1 opened this issue Jun 19, 2024 · 15 comments

Comments

@Aleksid1
Copy link

Aleksid1 commented Jun 19, 2024

I need to build a tiny shared FFmpeg. I removed many .sh files in /scripts.d/ directory with unused libs for my app. However it ignores my changes and build a heavy FFmpeg as with all default libs included in gpl-shared variant. What am I doing wrong?

@BtbN
Copy link
Owner

BtbN commented Jun 19, 2024

You probably forgot to build a new image. If you only run build.sh, it'll download the latest image from github with everything in it.

@Aleksid1
Copy link
Author

Many thanks for your quick response and great support! You're right. I'll try tomorrow.

@BtbN
Copy link
Owner

BtbN commented Jun 19, 2024

If you only modified scripts, and not the core-image, you can also export QUICKBUILD=1 before making the new image. It'll download the base images from github then, and only build your local scripts.

@Aleksid1
Copy link
Author

Thanks for the advice with export QUICKBUILD=1
I added this line to my .sh script before the makeimage command.
Is there a way to determine which lib from the /scripts.d directory is required? I removed about 30 libs to build tiny FFmpeg. And when I tried to create a new image, I was missing freetype, then libvmaf, etc.

@BtbN
Copy link
Owner

BtbN commented Jun 20, 2024

Nothing from there is strictly required, except for maybe the very basic mingw stuff at the lowest numbers.
There are complex inter-dependencies though, and if you remove something from a number below 50, you can expect something from a higher number to fail.
FFmpeg itself will happily build without any of it though.

@Aleksid1

This comment was marked as resolved.

@Aleksid1
Copy link
Author

Aleksid1 commented Jun 25, 2024

I tried to makeimage without any changes in your scripts. Regrettably it fails:

" => [layer-50-onevpl 1/1] RUN --mount=src=scripts.d/50-onevpl.sh,dst=/stage.sh --mount=src=.cache/downloads/50  1469.8s
 => [layer-50-openh264 1/1] RUN --mount=src=scripts.d/50-openh264.sh,dst=/stage.sh --mount=src=.cache/download  1442.7s
WARNING: local cache import at .cache/ghcr.io/btbn/ffmpeg-builds/win64-lgpl-shared-6.1_latest not found due to err: could not read .cache/ghcr.io/btbn/ffmpeg-builds/win64-lgpl-shared-6.1_latest/index.json: open .cache/ghcr.io/btbn/ffmpeg-builds/win64-lgpl-shared-6.1_latest/index.json: no such file or directory
ERROR: failed to receive status: rpc error: code = Unavailable desc = error reading from server: EOF
+ rm -f /tmp/tmp.9tO2rq6t60.toml"
docker builder prune --all
git clone https://github.com/BtbN/FFmpeg-Builds.git
cd FFmpeg-Builds
export QUICKBUILD=1
./makeimage.sh win64 lgpl-shared 6.1

WSL2 / Ubuntu 24.04

@BtbN
Copy link
Owner

BtbN commented Jun 25, 2024

That looks to me like a network issue or temporary outage of something.
It should not be talking to Github at that point, so probably some internal issue of Docker?
Make sure your docker installation is intact and up to date.

@Aleksid1
Copy link
Author

Thanks for your support!
I recently downloaded Docker for WSL2 from Microsoft Store.
I'll try with native Ubuntu without WSL2.

@BtbN
Copy link
Owner

BtbN commented Jun 25, 2024

I never used the store version.
I usually just install docker proper on WSL these days, since that works just fine if systemd is enabled.

@Aleksid1
Copy link
Author

I reinstalled Ubuntu 24.04 on WSL2 and installed docker from the console (not Docker Desktop). The same problem.
Is it possible to disable use of cache for docker in your script?

@BtbN
Copy link
Owner

BtbN commented Jun 26, 2024

It has nothing to do with any caching. The cache warning is normal if there is no cache yet.
Building works perfectly fine for me, so I have no idea what causes this for you.

@jhkim-104
Copy link

Hello. I had a similar experience and solved it.

The problem in my environment was that the memory and swapzone on the wsl side was not set properly with the .wslconfig settings.

I had previously had a wsl2 side error, so I had put a limit on memory usage in .wslconfig and had swap set to 0.

Due to this issue, during the docker image creation, cache, etc. was not created properly due to insufficient memory and the script crashed and terminated without a proper error message.

I have since reset the wslconfig settings to allow enough memory and swap and the issue was resolved.

It would be nice if you could include a warning for users on the WSL side to prevent unfortunate situations like mine.

@Aleksid1
Copy link
Author

Thanks for your advice! I'll try again to build a custom build.

@Aleksid1
Copy link
Author

Aleksid1 commented Aug 23, 2024

Many thanks for your advice! I successfully created a custom build for FFmpeg.

I removed some unused libs (in scripts.d dir) to build a tiny FFmpeg custom build. My script:

export QUICKBUILD=1
./makeimage.sh win64 gpl 6.1
./build.sh win64 gpl 6.1

I created in a new file .wslconfig in C:\Users\MyUserProfile\.wslconfig

[wsl2]
memory=7GB
swap=0

Then Docker worked correctly, BtbN's scripts produced custom image and then custom build for FFmpeg.

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

No branches or pull requests

3 participants