-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Practical guide to reading video files #1012
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
Conversation
In a scientific context, it is usually better to avoid these formats in favor | ||
of a simple directory of images or a multi-dimensional TIF. But video files are | ||
in widespread use, and they are easy to share, so it is convenient to be | ||
equipped to read them as image data when necessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add a note about these formats being (possibly) lossy.
I made some changes in response to comments by @tacaswell and @sciunto and rebased. |
install, especially because | ||
it must be linked to FFmpeg to support reading video from files. | ||
Even if installed correctly, it is known to get the meta data wrong | ||
for some video codecs [I have a citation for this somewhere...]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to your self should be fixed.
@stefanv, this is probably ready to merge, pending any additional remarks from @sciunto or @tacaswell. More could be added, and will surely need to be updated in time, but as it stands it is a good, brief review of the available tools. |
PIMS and MoviePy take a more pragmagic approach, perhaps a surer bet for | ||
the present, but ultimately slower, less powerful, and less flexible. | ||
|
||
### Seeking |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would move this note after the second paragraph. Do others agree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's reasonable. I guess I planned to have more to say about it, but as it is it feels like a short, orphaned subsection. I will change.
Changes Unknown when pulling 5d1d28f on danielballan:video-guide into * on scikit-image:master*. |
What I'm still missing are command lines for doing the conversion, a la http://matplotlib.org/faq/howto_faq.html#make-a-movie |
@danielballan What do you think about that suggestion? |
Absolutely; it's good suggestion. This should enable users to get going quickly and easily. I will find time for it shortly. |
Thanks, I very much appreciate you writing this up. |
Coincidentally, I just deleted that section of the FAQ (not merged yet) for being terribly out of date (as it does not mention the |
Note by @cgohlke on the mailing list:
|
decode (but not read) all the preceding frames. | ||
|
||
Why? Frames in video files are grouped into packets by *time*, not frame | ||
nubmer, and packets may not contain exactly the same number of frames. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
Since that section of the mpl docs cannot be used any more, should we show how to split a movie into individual frames from the command line using ffmpeg and vlc? |
Since the SciPy conference, PyAV has got better packaging and py3 compatibility, through my efforts and others'. On Linux/OSX, I think that is what we should recommend. The latest release of PIMS wraps PyAV in this file. For scientific applications, we generally require random access by frame number, as opposed to random access by (approximate!) time. The PIMS wrapper builds a "table of contents" by scanning each packet. I am pretty sure it is the fastest possible accurate solution. Something like this should work its way into scikit-image in time. For now I can write up a minimal example that uses PyAV directly and a minimal example using PIMS. As for Windows, I was not aware of Golke's video code and I'm very glad to know about it. For consistent results across platforms, I'd still like to see PyAV working on Windows someday, and I think it's possible. A good first step would be to get conda FFmpeg builds (with shared linking). Currently, even the Linux conda recipe is buggy. But for the present: I will rewrite recommending PyAV or PyAV + PIMS for Linux/OSX and Golke's code for Windows. Perhaps we can package it on PyPI. Sound good? |
That sounds like a plan to me! Will you guys take this one further--I'm |
@danielballan, would you like me to package |
BTW, I've used VideoCapture in the past with success. |
Yes, please do! I will crank out conda builds as well. On Tue, Oct 14, 2014 at 3:19 PM, Steven Silvester [email protected]
|
Hmm, not as easy as I'd hoped. Compilation relies on a hard-coded path to the |
I tried installing DirectX 9.0 SDK and the Windows SDK and could not find the libraries referenced in the source file. My goal was to distribute as a binary wheel, but I'm about fed up in general with Windows... |
@holtzhau I think you two should start a support group. |
Yeah I'm about ready to toss my Windows install disks and fold my arms. |
@holtzhau Had the dubious honour of recently freezing a scikit-image and OpenCV application for distribution on Windows. |
Hahaha, please! Sometimes I stare balefully at binstar search results hoping for rescuer. |
Aha! I was not aware of the |
Yes, the wheel includes ffmpeg. Here's the repo that does the build: https://github.com/MacPython/PyAV-wheels It works the same way as the matplotlib wheel builds - the repo builds the library dependencies that OSX does not have by default, then uses the delocate utility to copy the required libraries into the package directory tree, and relink them. I don't use conda myself because it seems unwise to make conda / Anaconda the only standard way of installing on OSX, but luckily for me, pip and virtualenvs are a pleasure to use on OSX now, because all the packages I install regularly have wheels. |
I opened an issue for the automated wheel building on PyAV : PyAV-Org/PyAV#89 |
Thanks for explaining. This is great! The more working solutions, the better! |
Matthew, this is excellent. Is there any progress on a delocate for Linux? |
Daniel, are we about ready to merge here? |
No, no progress on a delocate for Linux I'm afraid. I get so busy... If someone would like to help, I will try and carve out more time. |
@stefanv I just pushed an update with more details and new links to build recipes and benchmarks. I also included brief installation instructions for each package, since packaging difficulties are a major consideration here. |
With one more review, this should be ready to go. |
Thanks @danielballan, this looks great. Some failures in building the docs, but as soon as those are fixed we can merge. |
Travis is happy. Appveyor looks like it's failing on an unrelated issue with scipy. |
Practical guide to reading video files
Thank you very much for this excellent guide @danielballan; merged in 448230d |
@stefanv see https://travis-ci.org/scikit-image/scikit-image/jobs/211736423:
|
^ Should be fixed with c1d5320. |
Thanks for the fixup, @soupault. |
@danielballan not at all. |
+1. It's extremely valuable to have a page summarizing the shooting range of the different libraries. |
Here is a start on the documentation requested by @stefanv in #850.
It needs better links, both external and to other sections of the documentation within scikit-image. I made no attempt to get the sphinx right yet. This is just a draft.
Also, this is opinionated, but I attempt to show each project's strengths and shortcomings. As discussed in #850, I do not believe an optimal solution exists yet. Once this is ready to merge I will solicit the input of the creators of various projects I mention. I hope they will feel that I give each project a fair, if brief, treatment here.
Is this on the right track?