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

updated to v3.29.1 #11

Closed
wants to merge 3 commits into from
Closed

updated to v3.29.1 #11

wants to merge 3 commits into from

Conversation

muelli
Copy link
Collaborator

@muelli muelli commented Dec 11, 2020

This doesn't build, because the new package, ffmpeg-ffprobe-static requires Internet access during build time :(

Maybe @marcello3d can shed some light into making it build offline, e.g. by telling how to provide the required executables upfront.

@flathubbot
Copy link
Contributor

Started test build 34386

@flathubbot
Copy link
Contributor

Build 34386 failed

@marcello3d
Copy link

marcello3d commented Dec 11, 2020

@muelli the library runs an install script that downloads the binaries from the GitHub release depending on platform/arch. You could manually do that, but then you don't need the library in the first place. :)

@mifi
Copy link
Collaborator

mifi commented Dec 11, 2020

ffmpeg-ffprobe-static is forked from https://github.com/eugeneware/ffmpeg-static which also downloads ffmpeg from the internet. (I used that package up until now) I don't understand how ffmpeg-ffprobe-static is any different, other than also downloading ffprobe in addition

@muelli
Copy link
Collaborator Author

muelli commented Dec 11, 2020

The ffmpeg-static package supports, albeit clunky, pre-downloaded executables: eugeneware/ffmpeg-static#37
Is the same mechanism supported by the new package?

@muelli
Copy link
Collaborator Author

muelli commented Dec 11, 2020

You could manually do that,

I'd love to. But it's unclear to me, how I would do that.

@mifi
Copy link
Collaborator

mifi commented Dec 11, 2020

Is the same mechanism supported by the new package?

Doesn't seem like it:

https://github.com/eugeneware/ffmpeg-static/search?q=FFMPEG_BIN
https://github.com/descriptinc/ffmpeg-ffprobe-static/search?q=FFMPEG_BIN

@mifi
Copy link
Collaborator

mifi commented Dec 11, 2020

Is it possible to enable internet access during build? Or use the prebuilt linux binary from here: https://github.com/mifi/lossless-cut/releases/tag/v3.29.1
The automatic build process at losslesscut is GitHub Actions which has internet access so there it's no problem

@muelli
Copy link
Collaborator Author

muelli commented Dec 11, 2020

Is it possible to enable internet access during build?

No. This is not possible. Flathub doesn't allow that. For good reasons. No serious software distribution does that, AFAIK. It should be known at build time, which bytes go into the build which produces the artefacts produced for users.

Or use the prebuilt linux binary from here: https://github.com/mifi/lossless-cut/releases/tag/v3.29.1

That'd be possible, but it'd be much preferred to build from source.

@mifi
Copy link
Collaborator

mifi commented Dec 11, 2020

No. This is not possible. Flathub doesn't allow that. For good reasons. No serious software distribution does that, AFAIK. It should be known at build time, which bytes go into the build which produces the artefacts produced for users.

That makes sense

That'd be possible, but it'd be much preferred to build from source.

Understandable. But using ffmpeg-static, ffmpeg is also not built from source, because that package uses prebuilt ffmpeg binaries. Or does this flathub build script also build ffmpeg from source?

@mifi
Copy link
Collaborator

mifi commented Dec 11, 2020

I do build ffmpeg/ffprobe from source for losslesscut automaticlaly using github actions, but only for MacOS as of now: https://github.com/mifi/ffmpeg-build-script
I want to also build for windows/linux but I haven't gotten that far. If someone is up to the task that would be great.

@muelli
Copy link
Collaborator Author

muelli commented Dec 11, 2020

Understandable. But using ffmpeg-static, ffmpeg is also not built from source, because that package uses prebuilt ffmpeg binaries. Or does this flathub build script also build ffmpeg from source?

Right. I think there are two parts to that. Firstly, it'd be nice to build everything from source. It's not a strict requirement, though. The offline build is. And building v3.29.0 requires ffmpeg-static which can only be installed when certain files have been put in place before, i.e. the ffmpeg executables. Cf.

- type: file
url: https://github.com/eugeneware/ffmpeg-static/releases/download/b4.2.2/linux-x64
sha256: a5bdddd568b33d279602673499a1a2ba84962a4a3b0ddb6d6e753cbefa4679e6
dest-filename: ffmpeg-static

Secondly, but I think that's a minor detail, there is an ffmpeg executable in the runtime:

org.freedesktop.Platform.ffmpeg-full:
but I don't think it is being used.

So yeah, taking the whole app as a BLOB and shipping it to users is an option, but I consider it the worst. Making it build with all dependencies pre-loaded is my favourite. Bonus points if all sub-dependencies (e.g. ffmpeg) can be either built or taken from the system.

@mifi
Copy link
Collaborator

mifi commented Dec 13, 2020

I could add code in the app that uses the system installed ffmpeg and ffprobe for linux, but I would then need to know how to query this runtime, and how to get the paths to those (PATH?)

@muelli
Copy link
Collaborator Author

muelli commented Dec 13, 2020

Yeah, that could work. I don't understand why you would need to find the path rather than just executing the name and hoping for the best, but I consider that secondary, anyway. Right now, for the flathub package, the ffmpeg-ffprobe-static dependency is a problem and needs to be capable of being installed offline. It'd be nice if it could check whether the contents it wants to download already exists.

@mifi
Copy link
Collaborator

mifi commented Dec 13, 2020

I could execute the ffmpeg and ffprobe commands from PATH, and in such case I would use https://github.com/npm/node-which which would find this for me automatically.

I'm not sure how ffmpeg-static will allow offline install, looking at install.js it seems to also exit with an error if download fails?

I think the optimal would be to go back to ffmpeg-static, but then someone would need to implement the ffprobe support there
eugeneware/ffmpeg-static#19 (comment)

@muelli
Copy link
Collaborator Author

muelli commented Dec 14, 2020

I could execute the ffmpeg and ffprobe commands from PATH, and in such case I would use https://github.com/npm/node-which which would find this for me automatically.

yeah, that sounds good :)
I guess, though, that you're having certain requirements in terms of the version or features of those executables. And you might not like the proliferation of ffmpegs that users come to you with and complain about things not working.

I'm not sure how ffmpeg-static will allow offline install, looking at install.js it seems to also exit with an error if download fails?

I guess this line makes it work: https://github.com/eugeneware/ffmpeg-static/blob/55975393f91e091a2083400477c18393f197a09e/install.js#L28

The ffmpeg-ffprobe-static package has a very similar mechanism:

https://github.com/descriptinc/ffmpeg-ffprobe-static/blob/de47039ccfbedeaa5d56bb32a1d78bdffe4b8516/install.js#L28

So it could work by placing something in the right folder. But instead of me guessing which files the package expects there, I'd appreciate if @marcello3d could chime in to tell me what file (and preferably its hash) to put where.

I think the optimal would be to go back to ffmpeg-static, but then someone would need to implement the ffprobe support there
eugeneware/ffmpeg-static#19 (comment)

I'm not entirely convinced. Unless @marcello3d objects, I have the feeling that enabling the package to be installed offline is the better approach. But in the end it doesn't matter much.

@mifi
Copy link
Collaborator

mifi commented Dec 14, 2020

Great find! I think it would be like this then:

https://github.com/descriptinc/ffmpeg-ffprobe-static/releases/download/b4.3.1-rc.5/ffmpeg-linux-x64
-> lossless-cut/node_modules/ffmpeg-ffprobe-static/ffmpeg
https://github.com/descriptinc/ffmpeg-ffprobe-static/releases/download/b4.3.1-rc.5/ffprobe-linux-x64
-> lossless-cut/node_modules/ffmpeg-ffprobe-static/ffprobe

It doesn't build, though :(

It seems the directory is re-created.
Here we can see that the files are indeed in that directory.
When the build fails, the diretory looks different, i.e. as if it has
been re-created.
@flathubbot
Copy link
Contributor

Started test build 34608

@muelli
Copy link
Collaborator Author

muelli commented Dec 14, 2020

Doesn't work, unfortunately :(

It seems the directory is re-created, i.e. the files disappear.

@flathubbot
Copy link
Contributor

Build 34608 failed

@marcello3d
Copy link

All ffmpeg-static does is make it so you don't have to manually download and copy these prebuilt static libraries and gives you the path to them in node_modules. My fork just adds ffprobe.

If you're downloading them manually/"offline" then you don't need the module.

@mifi
Copy link
Collaborator

mifi commented Dec 14, 2020

The problem is that the official build process of losslesscut doesn't manually download and copy the files. If it's a lot of trouble getting it all to work, then maybe I should ditch the whole ffmpeg-ffprobe-static and instead create a pre-build step in the official build process that downloads the right ffmpeg first.

@marcello3d
Copy link

It seems like what you want to do, since this is Linux, is not bundle ffmpeg/ffprobe at all and depend on a shared system version. That'll make the app a lot smaller, too.

@mifi
Copy link
Collaborator

mifi commented Dec 14, 2020

Yea if flathub can specify an ffmpeg version requirement in its "spec" file, that ensures the user has already installed a specific version of ffmpeg, then we could do that

@muelli
Copy link
Collaborator Author

muelli commented Dec 14, 2020

If you're downloading them manually/"offline" then you don't need the module.

I don't agree with your reasoning, but I don't think it matters. I think the author of a piece of software could very well depend on the package reliably providing "ffprobe" while a distributor, at the same time, builds that software offline.

Would you object if anybody provided a patch to make the module offline installable?

@muelli
Copy link
Collaborator Author

muelli commented Dec 14, 2020

Yea if flathub can specify an ffmpeg version requirement in its "spec" file, that ensures the user has already installed a specific version of ffmpeg, then we could do that

AFAIU, the "Freedesktop Runtime" as of 20.08 commits to shipping ffmpeg 4.3.
I don't fully understand how the runtime is composed, but ffmpeg is there and I think the policy is to not bump versions and only provide security fixes.

@muelli
Copy link
Collaborator Author

muelli commented Dec 14, 2020

My fork just adds ffprobe.

and it seems to remove the ability to install the package offline :-(

@marcello3d
Copy link

and it seems to remove the ability to install the package offline :-(

That was a change on the original ffmpeg-static package, not part of my fork. Previously it would download all platform/arch binaries every time. Now it just downloads your system's platform/architecture.

I'm sorry it doesn't work for you, feel free to make your own module! :-) As I said, they're not doing much of anything other than packaging the binaries in a manner more useful for node/electron.

@mifi
Copy link
Collaborator

mifi commented Dec 14, 2020

AFAIU, the "Freedesktop Runtime" as of 20.08 commits to shipping ffmpeg 4.3.

Oh and losslesscut flathub depends on freedesktop runtime? Then the only problem is that I need to know somehow inside the JS code that we are running the flathub version. Or I just default to trying the system ffmpeg/ffprobe if the included binaries fail to run on linux.

Ohh and somehow we must make the ffmpeg-ffprobe-static installation not crash if offline, am i right? Or remove it entirely

@muelli
Copy link
Collaborator Author

muelli commented Dec 14, 2020

Oh and losslesscut flathub depends on freedesktop runtime?

Ah, yes:

runtime: org.freedesktop.Platform

Then the only problem is that I need to know somehow inside the JS code that we are running the flathub version

Apps run inside a flatpak container expose /.flatpak-info. I don't think hard-coding anything for a flatpaked version is necessary.

Ohh and somehow we must make the ffmpeg-ffprobe-static installation not crash if offline, am i right? Or remove it entirely

yes. This is the actual blocker here. All the other things like running the correct ffmpeg executable can easily be achieved, I think, if only by symlinking executables into the right place or manipulating PATH.

@muelli
Copy link
Collaborator Author

muelli commented Dec 14, 2020

That was a change on the original ffmpeg-static package, not part of my fork.

ah. weird then. Maybe @derhuerst can comment on whether or how it's possible to install the package offline or what caused this ability to be removed.

@derhuerst
Copy link

derhuerst commented Dec 16, 2020

Maintainer of ffmpeg-static here, and thus maintainer of the code that the ffmpeg-ffprobe-static fork uses. Not sure if it's still relevant, but I'm going to answer for everyone interested.

I'm not sure how ffmpeg-static will allow offline install [...]?

It does. You can set the FFMPEG_BIN env var:

export FFMPEG_BIN=/bin/bash
npm i ffmpeg-static
# > ffmpeg-static@4.2.7 install /Users/j/playground/node_modules/ffmpeg-static
# > node install.js
#
# ffmpeg is installed already.
# + ffmpeg-static@4.2.7
node -p 'require("ffmpeg-static")'
# /bin/bash

When doing this, I don't really see the point of using ffmpeg-static/ffmpeg-ffprobe-static anymore though: You'll need to detect the platform & arch and download the appropriate binary by yourself, so you're basically doing exactly what ffmpeg-static/ffmpeg-ffprobe-static is supposed to do.

The FFMPEG_BIN mechanism is intended to force a lib/tool using ffmpeg via ffmpeg-static/ffmpeg-ffprobe-static to use your own binary, but it can of course also be used to prevent network access.

looking at install.js it seems to also exit with an error if download fails?

Yes, because it couldn't do the thing it's supposed to do: Provide a self-contained (as in independent of system-installed binaries) & platform-specific binary to npm-based tools.

I think the optimal would be to go back to ffmpeg-static, but then someone would need to implement the ffprobe support there
eugeneware/ffmpeg-static#19 (comment)

As I said in the linked comment, I agree by now that adding ffprobe to ffmpeg-static is a good idea; Someone just needs to submit a PR, or wait for me to find time to do it. But that doesn't solve the problem, as you're essentially making ffmpeg-static/ffmpeg-ffprobe-static obsolete by overriding its download script.

@derhuerst
Copy link

Regarding the "no network access during builds" thing: You could of course run npm i ffmpeg-static before, then copy the download binary to a dedicated place (cp $(node -p 'require("ffmpeg-static")' ./ffmpeg) and then run the build with FFMPEG_BIN=./ffmpeg.

But I don't think it's worth the hassle/complexity, I'd rather argue that we should all work towards a trusted host/API from which ffmpeg binaries for all plattforms/arches can be downloaded with a simple one-liner. (That could of course be the ffmpeg-static GitHub releases, but I would prefer to have a more independent place)

@muelli
Copy link
Collaborator Author

muelli commented Dec 16, 2020

Thanks for your input!

and then run the build with FFMPEG_BIN=./ffmpeg.

Right. We made it work for the ffmpeg-static package. That capability seems to be missing from the ffmpeg-ffprobe-static package, though. At least, I cannot see how to make that work.
As has already been mentioned, @marcello3d seems to have removed the handling of the FFMPEG_BIN environment variable. With that variable, we could probably make it work. It should be easy to patch it back in, I suppose. But maybe there's a reason why it has disappeared.

But I don't think it's worth the hassle/complexity, I'd rather argue that we should all work towards a trusted host/API from which ffmpeg binaries for all plattforms/arches can be downloaded with a simple one-liner

I don't think these goals are mutually exclusive. Here, we have the case that a software package depends on (a variant of) ffmpeg-static, because it wants to ensure that an ffmpeg executable is present. Regardless of operating system or architecture. In order to package this software up for distribution to users, we, as distributors, now want to say, "please, please, don't download anything from the Internet, as we consider it a big waste of resources and makes auditing the software nearly impossible, and take this ffmpeg instead".

@derhuerst
Copy link

[...] Here, we have the case that a software package depends on (a variant of) ffmpeg-static, because it wants to ensure that an ffmpeg executable is present. Regardless of operating system or architecture. In order to package this software up for distribution to users, we, as distributors, now want to say, "please, please, don't download anything from the Internet, as we consider it a big waste of resources and makes auditing the software nearly impossible, and take this ffmpeg instead".

If you want something auditable, then relying on ffmpeg binaries provided by random strangers on the internet™ is probably not a good idea either. 😃 Let's set up a repo with the sole purpose of hosting the ffmpeg binaries, with their hashes, links to build scripts, etc. Eventually, we could enhance it to build the binaries from source.

The losslesscut build would then pull its binary from this repo, just like ffmpeg-static would.

@muelli
Copy link
Collaborator Author

muelli commented Dec 16, 2020

If you want something auditable, then relying on ffmpeg binaries provided by random strangers on the internet™ is probably not a good idea either.

Sure. You are absolutely right. I wish the whole ecosystem worked entirely differently. But that ship has sailed. So two things there: Firstly, with ffmpeg-static, rather than ffmpeg-ffprobe-static, we can ignore the BLOB from the Internet and have our own version run. Secondly, we're not even trying to fix everything, but make things better step by step. And if we can control the build, as in, not relying on the Internet as an input to our build, we can perform audits much much easier, because the build is deterministic. Hence, less fragile, less dependent on the mercy of other parties, it has chances of being reproducible, the build infrastructure can be greatly simplified, and many other benefits.
So I'd be appreciate if the needs of offline builds can at least be considered. Again, this is not so much a concern for ffmeg-static, as it can be built offline, but much more for ffmpeg-ffprobe-static.

@derhuerst
Copy link

So I'd be appreciate if the needs of offline builds can at least be considered. Again, this is not so much a concern for ffmeg-static, as it can be built offline, but much more for ffmpeg-ffprobe-static.

As ffmpeg-ffprobe-static is a fork of ffmpeg-static, @descriptinc would have to rebase their master to support this.

@derhuerst
Copy link

In the ffmpeg-static repo, someone asked how to use it with Electron. I think this is a common use case, ideally we can write a guide on how to use it, and document the limitations with deterministic/offline build systems mentioned above.

I could assist with this or proof-read it, but I have neither the energy nor the Electron-specific knowledge to drive this by myself. Anyone willing to do this?

mifi added a commit to mifi/lossless-cut that referenced this pull request Nov 13, 2021
except mac
Remove ffmpeg-ffprobe-static, use scripts instead

flathub/no.mifi.losslesscut#11
@muelli
Copy link
Collaborator Author

muelli commented Nov 15, 2021

superseded

@muelli muelli closed this Nov 15, 2021
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.

None yet

5 participants