lossless-cut icon indicating copy to clipboard operation
lossless-cut copied to clipboard

[Feature request] Smaller disk footprint

Open skycommand opened this issue 3 years ago • 17 comments

Hello. 😊

After installing LosslessCut today, I noticed that its disk footprint could be significantly smaller. Currently, LosslessCut comes with two large files, FFmpeg.exe and FFprobe.exe, which occupy 182 MB. They are from the static build of FFmpeg.

You could reduce this 182 MB to half if you use the shared build of FFmpeg. There is only a small drawback: Instead of two files, you have to include 10 files. (LosslessCut already has 71.)

Here is where to get the shared build (click here to expand)

FFmpeg builds

skycommand avatar May 10 '22 01:05 skycommand

Hi! i'm not sure if this could have some other negative implications. I'm thinking that because they are not static builds, they might be missing some dependencies that are not installed on all computers, like core Windows libraries that might differ from OS to OS, possibly causing users to get an error if they are missing thse dependencies or have the wrong version

mifi avatar May 12 '22 19:05 mifi

Hi again.

The concern you are voicing is called "dependency hell." It is a known problem of Linux, not Windows. Ironically, the absence of dependency hell in Windows is because of its non-free, closed-source nature.

If you are still in doubt, you can:

  • Run a dependency walker.

    I did it for you. Here are the details.

    FFmpeg.exe takes a dependency on the following files:

    • Part of Windows since ancient times
      • ADVAPI32.dll
      • KERNEL32.dll
      • msvcrt.dll
      • SHELL32.dll
    • Part of the FFmpeg package; you need to include them
      • avcodec-59.dll
      • avdevice-59.dll
      • avfilter-8.dll
      • avformat-59.dll
      • avutil-57.dll
      • postproc-56.dll
      • swresample-4.dll
      • swscale-6.dll
  • Test your app on all three versions of Windows released in the last ten years. (Testers can have them free of charge.)

  • Let me test your app on five different versions of Windows released in the last 15 years. I can create videos and upload them here.

skycommand avatar May 13 '22 01:05 skycommand

Thanks for researching. This is definitely an improvement that I should test. I'm not sure why the static builds are so much larger though. One would think that linking the exact same code but instead in a static way would yield approximately the same size as the sum of the non-static dlls

mifi avatar May 21 '22 22:05 mifi

Hello, @mifi. I made this simple request 17 releases ago, all of which could have had smaller sizes. I hate to be pushy but fulfilling this request takes very little time.

skycommand avatar Apr 04 '23 15:04 skycommand

Hi. Im not using BtbN builds now. Am using gyan essentials build, so I would need to find out which build (if any) in btbn corresponds with the one I’m using now. Did you figure out why shared builds are smaller than static builds? Is it because ffmpeg and ffproble commands don’t need to duplicate their common dependencies?

mifi avatar Apr 05 '23 01:04 mifi

I would need to find out which build (if any) in btbn corresponds with the one I’m using now.

Please see the screenshot I've posted. I've marked the correct item.

That said, Gyan has shared builds too. Here is a comparison of their extracted sizes.

Build name Size of the bin folder
Gyan, Essential, static build 231 MB
Gyan, Essential, static build, without ffplay.exe 154 MB
Gyan, Full, shared build 136 MB
BtBn, GPL, shared build 125 MB

Since Gyan's full shared build is already small, he doesn't make essential shared builds.

Did you figure out why shared builds are smaller than static builds? Is it because ffmpeg and ffproble commands don’t need to duplicate their common dependencies?

Exactly. That's essentially why DLLs were invented – to reduce the app size by eliminating code duplication.

skycommand avatar Apr 05 '23 01:04 skycommand

Ok i will try to use those for ffmpeg 6

mifi avatar Apr 05 '23 03:04 mifi

Ive created a build that seems to pass. maybe you can test it: https://github.com/mifi/lossless-cut/actions/runs/4614814877 scroll down to find the artifacts

mifi avatar Apr 05 '23 04:04 mifi

I tried three projects with it. I can't even feel a difference!

skycommand avatar Apr 05 '23 14:04 skycommand

ok, should be all good then!

mifi avatar Apr 06 '23 15:04 mifi

do you happen to know if this also works for linux? i did the same for .so files (same as for .ddl files, place them in the same directory), but I don't know if that will actually work.

mifi avatar Apr 06 '23 15:04 mifi

I grabbed a copy of Ubuntu and tested it. It was tricky. Here is a screenshot.

Ubuntu 64-bit-2023-04-07-05-36-58

Do you see those blue items, each with a 20—22 bytes size? They are symbolic links. (A symbolic link is not an actual file. It points to another file.) You need to be careful so as to preserve those.

skycommand avatar Apr 07 '23 02:04 skycommand

I believe they are already preserved in LosslessCut, aren't they? Did you try to run losslesscut from the linux binary from here? https://github.com/mifi/lossless-cut/actions/runs/4614814877

mifi avatar Apr 07 '23 03:04 mifi

Yes. You have. A beta release will tell you if everything works.

skycommand avatar Apr 07 '23 07:04 skycommand

what were the results when you tried to run dynamic linked ffmpeg on ubuntu?

mifi avatar Apr 07 '23 08:04 mifi

Here is how I got ffmpeg to work, with no symlinks. Ubuntu 64-bit-2023-04-07-20-23-30

Here is proof that it worked. Ubuntu 64-bit-2023-04-07-20-46-15

And here is LosslessCut using it. Ubuntu 64-bit-2023-04-07-20-49-19

skycommand avatar Apr 07 '23 18:04 skycommand

nice, thanks. do you have ffmpeg (libav*) insalled in your system though? I'm afraid it's using those instead.

I think I will do something like this to be safe:

spawn('ffmpeg', [], {env: {LD_LIBRARY_PATH: '/path/to/losslesscut'}})
  • https://stackoverflow.com/questions/51930254/run-a-binary-file-with-shared-object-dependencies-on-nodejs-express-server
  • https://stackoverflow.com/questions/25356641/distribute-so-file-on-linux

mifi avatar Apr 08 '23 12:04 mifi