You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently have two formats for video. Avbin and ffmpeg. Avbin wraps a binary from 2012, so we should probably deprecate that. We have quite a bit of problems with the ffmpeg plugin, most notably the difficulty of retrieving the right fps and number of frames. In this issue I hope to get some ideas of what our options are ... please discuss.
Maybe we can help PyAv with automating the building of their binary wheels?
It has been suggested to use ffprobe to collect metadata about a video file. Although this adds another dependency, it's kinda part of ffmpeg, and maybe it can solve most our issues.
@hmaarrfk, you mentioned pyffmpeg, I see two of these on Github. Would it be worth depending on something like that? Or examine the code and improve our ffmpeg plugin based on what we learn?
Other ideas?
If anyone is eager to champion this effort, that would be great 👍 !
In terms of packaging, a library that wraps ffmpeg could included the binaries (the ones that imageio makes easy to download) in the binary wheels. It must be possible to create those wheels from a single OS (because the binaries are pre-build). That way installation for users is easy, and without any of that download() stuff. Plus Linux packagers are happy because they can take the sdist instead. Right @ghisvail ?
I think the old pyffmpeg tried to hand wrap things. I think it was
unmaintainamble for them and the project became defunct.
I started doing that tying to constrain myself to encoding videos and it
soon became clear that it would be impossible.
This is because some structures would change size and contain new user
facing entries when compile options were invoked. I don’t know if it is
possible to read defined values with ctypes.
I started with a few swig wrappers in a different branch. That is honestly
the way to go. The challenge there is when you wrap C for python using
swig, the python code reads like C which is annoying at best, but also you
end up writing out the namespaces about 5 times because constants have the
namespace embedded in their name for C. I hope to be able to have some
simple encoding examples. A decoding example should be dooable at that
point.
The great thing there is that ffmpeg would share memory with python. That
is awesome if you use LGPL code, and maybe a bummer if you use GPL
(depending on who you ask it seems).
I hope to have a few examples that can call ffmpeg directly with more
pythonic wrappers but still expose the swig underlying structures in case
anybody needs them.
Swig would need knowledge of the underlying installed version of ffmpeg at
compile time. Meaning conda is likely the only reliable way to ship it in
binary form.
Man, I didn't know that PyAv was so advanced. I got stuck on pyffmpeg getting arrays wrapped with swig. C is just really hard to wrap since it is so low level. I'm going to look at PyAv more closely.
Swig would need knowledge of the underlying installed version of ffmpeg at compile time. Meaning conda is likely the only reliable way to ship it in binary form.
I consider this a serious drawback ...
I'm playing with the idea of spinning out our ffmpeg wrapper (i.e. calling the ffmpeg exe and send images over a pipe) into a separate package. The used method is not the fastest or easiests, but it does work with any ffmpeg version, making distribution much easier and flexible. By also making use of ffprobe, I hope we can overcome the limitations that currently bother us most (like getting fps and number of frames). We can push platform-specific wheels to pypi that include the binary exes (this is what I meant in my comment above).
I'm not sure there is a good pypi solution to these C dependencies. Rolling your own is a great stopgap solution, and definitely makes imageio "just work the first time", but makes things like security concerns problematic.
Isn't imageio basically the ffmpeg wrapper that you are talking about? Why would you want to rebuild the infrastructure for that other project?
Why would you want to rebuild the infrastructure for that other project?
Because that new library can become an optional dependency of imageio. That way imageio itself can stay light, while that new lib can include the binaries (ffmpeg and ffprobe) in the dist. (BTW, Linux distros can package that lib without the binaries and make it use the system ffmpeg instead.)
The workflow then becomes:
User installs imageio
User wants to use video, imageio gives error and hints to install this-new-lib
User does pip install this-new-lib
Bam, it works.
Also, libs like @Zulko 's moviepy can depend on that lib instead of imageio, instead of relying on imageio and somehow have the user invoke imageio.plugins.ffmpeg.download().
Sort of. But I don't want pip to compile ffmpeg if that's what you meant. I want pip to install the Python code, which works with about any ffmpeg. Then provide binary wheels that include a precompiled ffmpeg (like these). Maybe not on Linux, because Linux users usually can/want to apt-install it.
Activity
almarklein commentedon Nov 6, 2018
In terms of packaging, a library that wraps ffmpeg could included the binaries (the ones that imageio makes easy to download) in the binary wheels. It must be possible to create those wheels from a single OS (because the binaries are pre-build). That way installation for users is easy, and without any of that
download()stuff. Plus Linux packagers are happy because they can take the sdist instead. Right @ghisvail ?hmaarrfk commentedon Nov 7, 2018
hmaarrfk commentedon Nov 12, 2018
Man, I didn't know that PyAv was so advanced. I got stuck on pyffmpeg getting arrays wrapped with swig. C is just really hard to wrap since it is so low level. I'm going to look at PyAv more closely.
almarklein commentedon Nov 12, 2018
I consider this a serious drawback ...
I'm playing with the idea of spinning out our ffmpeg wrapper (i.e. calling the ffmpeg exe and send images over a pipe) into a separate package. The used method is not the fastest or easiests, but it does work with any ffmpeg version, making distribution much easier and flexible. By also making use of ffprobe, I hope we can overcome the limitations that currently bother us most (like getting fps and number of frames). We can push platform-specific wheels to pypi that include the binary exes (this is what I meant in my comment above).
hmaarrfk commentedon Nov 12, 2018
I'm not sure there is a good pypi solution to these C dependencies. Rolling your own is a great stopgap solution, and definitely makes imageio "just work the first time", but makes things like security concerns problematic.
Isn't imageio basically the ffmpeg wrapper that you are talking about? Why would you want to rebuild the infrastructure for that other project?
almarklein commentedon Nov 12, 2018
Because that new library can become an optional dependency of imageio. That way imageio itself can stay light, while that new lib can include the binaries (ffmpeg and ffprobe) in the dist. (BTW, Linux distros can package that lib without the binaries and make it use the system ffmpeg instead.)
The workflow then becomes:
pip install this-new-libAlso, libs like @Zulko 's moviepy can depend on that lib instead of imageio, instead of relying on imageio and somehow have the user invoke
imageio.plugins.ffmpeg.download().hmaarrfk commentedon Nov 12, 2018
So you want a pip installable ffmpeg. Sounds reasonable, but sounds difficult to get right with compiler restrictions.
almarklein commentedon Nov 13, 2018
Sort of. But I don't want pip to compile ffmpeg if that's what you meant. I want pip to install the Python code, which works with about any ffmpeg. Then provide binary wheels that include a precompiled ffmpeg (like these). Maybe not on Linux, because Linux users usually can/want to apt-install it.
almarklein commentedon Jan 29, 2019
I made a start on this here: https://github.com/imageio/imageio-ffmpeg
Edit: the main gist is here: https://github.com/imageio/imageio-ffmpeg/blob/master/tasks.py#L135
almarklein commentedon Feb 5, 2019
work in progress: #425