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

Packaging ffmpeg binary with moviepy #85

Closed
alexbw opened this issue Nov 13, 2014 · 12 comments
Closed

Packaging ffmpeg binary with moviepy #85

alexbw opened this issue Nov 13, 2014 · 12 comments

Comments

@alexbw
Copy link

alexbw commented Nov 13, 2014

Would be very convenient to have a "batteries included" install approach, where pip installing moviepy ensures you have some minimum version of ffmpeg. Would likely have to be platform specific.
Pre-built FFMPEG binary are available for every platform.
https://www.ffmpeg.org/download.html

@Zulko
Copy link
Owner

Zulko commented Nov 14, 2014

I asked Reddit and this here seems to answer the problem (enables to trigger events during installation). Looks not completely trivial and we must be careful not to force ffmpeg install on people that have an incompatible version and want to keep it. Another option would be an external script that you can run. For instance, after installing moviepy, you could run in a terminal

moviepy install_ffmpeg

And that would install/upgrade ffmpeg. I would prefer this as a first approach. Honnestly it's not on the top of my prioreties and I have no idea how to handle Windows/MacOS so if you can come up with a standalone script that does that I'd gladly merge it.

@Who8MyLunch
Copy link

An alternative idea is to leverage bits of code from the Imageio package (imageio.readthedocs.org) for automatically downloading platform-specific binaries. The relevant functionality appears to be mostly contained in this file: https://github.com/imageio/imageio/blob/master/imageio/core/fetching.py.
The binary files are stored locally, no need to install to the system.

edit: Hey! I just looked over imageio in a bit more detail. They include ffmpeg as one of their binaries. I think they already solved why I was trying to describe.

@Zulko
Copy link
Owner

Zulko commented Dec 1, 2014

Imageio's solution looks good. But then, should we automatically install ffmpeg during moviepy's installation, without warning, or make a second script ? To go further, maybe we could automatize a little:

if os.name == 'nt':
    if platform.architecture()[0] == '32bit':
        binary_name = 'ffmpeg32.exe'
etc.

Another question is: where should the ffmpeg binary be placed by default on the user's system ? On linux, it would be in /usr/bin. On mac, I don't really know, maybe /usr/bin too or /usr/local/bin. On windows, I have no clue. That's my main problem, I can only implement/check a solution for Ubuntu 12.04 32bit :)

I'm calling @almarklein into the discussion, he may have some ideas :)

@almarklein
Copy link

Here's some code to obtain the appdata dir for most platforms: https://github.com/imageio/imageio/blob/master/imageio/core/util.py#L364

@almarklein
Copy link

Some further thoughts about when to download such dependencies: you can install at build-time (i.e. ship the binary in the dist package), install-time, or run-time. I've learned that install-time is apparently not recommended for users who work in an environment without an internet connection, and is frowned upon in the Debian build process.

In imageio we have several of such dependencies, and I now try to find a way to ship the freeimage library at build-time, and have other binaries auto-dowloaded when needed (at runtime).

@Zulko
Copy link
Owner

Zulko commented Dec 1, 2014

@almarklein Thanks ! I'll look into it when I have time. Just to be sure I understand: when you build, you package different versions of imageio for different platforms, and send all these packages on PyPI, each with a different binary, is that right ?

@almarklein
Copy link

@Zulko Actually, I am still figuring out what to do (imageio/imageio#42). My idea was to create a wheel for each platform. In setup.py I added some code to "collect" the library for the current platform. This works, except that wheel thinks the package is pure Python because it did not build any C libraries :( Still thinking about how to proceed with this ... If you have an idea, I'd be happy to hear it.

@Zulko
Copy link
Owner

Zulko commented Dec 2, 2014

Ach, I have no experience at all with wheel or Python/C packaging. I didn't understand, is the C code yours, or is it for external software (e.g. ffmpeg) ? Because in this case you can surely ship the pre-compiled binary ?

@almarklein
Copy link

The C code is not mine. I mean that the problem is that it seems not possible to build platform specific pacakges (at least not with wheel), because wheel sees that the package is pure Python, and thus marks it as cross-platform.

@Zulko
Copy link
Owner

Zulko commented Dec 15, 2014

So now MoviePy depends on imageio. See issue #99 for discussion. This will need testing, but I think it solves your problem @alexbw. Could you try the last version of MoviePy (PyPI or Github) and confirm ?

@alexbw
Copy link
Author

alexbw commented Dec 15, 2014

Fantastic. Will test soon.
On Mon, Dec 15, 2014 at 3:58 AM Zulko notifications@github.com wrote:

So now MoviePy depends on imageio. See issue #99
#99 for discussion. This will
need testing, but I think it solves your problem @alexbw
https://github.com/alexbw. Could you try the last version of MoviePy
(PyPI or Github) and confirm ?


Reply to this email directly or view it on GitHub
#85 (comment).

@alexbw
Copy link
Author

alexbw commented Dec 29, 2014

This works very well for me, now. Thanks for this! Closing.

@alexbw alexbw closed this as completed Dec 29, 2014
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

4 participants