Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

danielballan
Copy link
Contributor

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?

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling bef08fe on danielballan:video-guide into 5b07567 on scikit-image:master.

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.
Copy link
Contributor

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.

@danielballan
Copy link
Contributor Author

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...].
Copy link
Contributor

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.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 2ab42eb on danielballan:video-guide into 3814df2 on scikit-image:master.

@danielballan
Copy link
Contributor Author

@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
Copy link
Member

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?

Copy link
Contributor Author

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.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 5d1d28f on danielballan:video-guide into * on scikit-image:master*.

@stefanv
Copy link
Member

stefanv commented Jun 23, 2014

What I'm still missing are command lines for doing the conversion, a la http://matplotlib.org/faq/howto_faq.html#make-a-movie

@stefanv
Copy link
Member

stefanv commented Jun 30, 2014

@danielballan What do you think about that suggestion?

@danielballan
Copy link
Contributor Author

Absolutely; it's good suggestion. This should enable users to get going quickly and easily. I will find time for it shortly.

@stefanv
Copy link
Member

stefanv commented Jun 30, 2014

Thanks, I very much appreciate you writing this up.

@tacaswell
Copy link
Contributor

Coincidentally, I just deleted that section of the FAQ (not merged yet) for being terribly out of date (as it does not mention the MovieWriter classes).

@stefanv
Copy link
Member

stefanv commented Oct 12, 2014

Note by @cgohlke on the mailing list:

In case you are using Windows, try vidsrc 
<http://www.lfd.uci.edu/~gohlke/code/vidsrc.cpp.html>, which reads frame 
data of video files via
Microsoft's DirectShow IMediaDet interface. Binaries are included in the 
vLFD package installer at <http://www.lfd.uci.edu/~gohlke/pythonlibs/#vlfd>

from vidsrc import VideoSource
video = VideoSource("test.avi")
for frame in video:
     print(frame.mean())

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo

@stefanv
Copy link
Member

stefanv commented Oct 12, 2014

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?

@danielballan
Copy link
Contributor Author

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?

@stefanv
Copy link
Member

stefanv commented Oct 13, 2014

That sounds like a plan to me! Will you guys take this one further--I'm
afraid my knowledge here is too little to contribute anything meaningful.

@blink1073
Copy link
Contributor

@danielballan, would you like me to package vidsrc the same way I did tifffile?

@blink1073
Copy link
Contributor

BTW, I've used VideoCapture in the past with success.

@danielballan
Copy link
Contributor Author

Yes, please do! I will crank out conda builds as well.

On Tue, Oct 14, 2014 at 3:19 PM, Steven Silvester [email protected]
wrote:

BTW, I've used VideoCapture http://videocapture.sourceforge.net/ in the
past with success.


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

@blink1073
Copy link
Contributor

Hmm, not as easy as I'd hoped. Compilation relies on a hard-coded path to the STRMBASE library from DirectShow.

@blink1073
Copy link
Contributor

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...

@stefanv
Copy link
Member

stefanv commented Oct 16, 2014

@holtzhau I think you two should start a support group.

@blink1073
Copy link
Contributor

Yeah I'm about ready to toss my Windows install disks and fold my arms.

@stefanv
Copy link
Member

stefanv commented Oct 16, 2014

@holtzhau Had the dubious honour of recently freezing a scikit-image and OpenCV application for distribution on Windows.

@danielballan
Copy link
Contributor Author

Hahaha, please! Sometimes I stare balefully at binstar search results hoping for rescuer.

@blink1073
Copy link
Contributor

Aha! I was not aware of the wheel convert command until just now. I will host the source code and a wheel file for vidsrc on PyPI. wheel convert - "Convert egg or wininst to wheel"

@matthew-brett
Copy link
Contributor

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.

@matthew-brett
Copy link
Contributor

I opened an issue for the automated wheel building on PyAV : PyAV-Org/PyAV#89

@danielballan
Copy link
Contributor Author

Thanks for explaining. This is great! The more working solutions, the better!

@stefanv
Copy link
Member

stefanv commented May 9, 2015

Matthew, this is excellent. Is there any progress on a delocate for Linux?

@stefanv
Copy link
Member

stefanv commented May 9, 2015

Daniel, are we about ready to merge here?

@matthew-brett
Copy link
Contributor

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.

@danielballan
Copy link
Contributor Author

@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.

@danielballan
Copy link
Contributor Author

With one more review, this should be ready to go.

@stefanv
Copy link
Member

stefanv commented May 17, 2015

Thanks @danielballan, this looks great. Some failures in building the docs, but as soon as those are fixed we can merge.

@danielballan
Copy link
Contributor Author

Travis is happy. Appveyor looks like it's failing on an unrelated issue with scipy.

@soupault soupault added 📄 type: Documentation Updates, fixes and additions to documentation ⏩ type: Enhancement Improve existing features labels Feb 4, 2016
@soupault soupault changed the title WIP/DOC: Practical guide to reading video files. Practical guide to reading video files Oct 25, 2016
stefanv added a commit that referenced this pull request Mar 15, 2017
Practical guide to reading video files
@stefanv
Copy link
Member

stefanv commented Mar 15, 2017

Thank you very much for this excellent guide @danielballan; merged in 448230d

@stefanv stefanv closed this Mar 15, 2017
@soupault
Copy link
Member

@stefanv see https://travis-ci.org/scikit-image/scikit-image/jobs/211736423:

Warning, treated as error:
/home/travis/build/scikit-image/scikit-image/doc/source/user_guide.rst:4: WARNING: toctree contains reference to nonexisting document u'user_guide/video'
make[1]: *** [html] Error 1
make[1]: Leaving directory `/home/travis/build/scikit-image/scikit-image/doc'
make: *** [html] Error 2

@soupault
Copy link
Member

^ Should be fixed with c1d5320.

@danielballan
Copy link
Contributor Author

Thanks for the fixup, @soupault.

@soupault
Copy link
Member

@danielballan not at all.
By the way, I've recently come across http://www.scikit-video.org/stable/ . Maybe we should add it also.

@sciunto
Copy link
Member

sciunto commented Mar 20, 2017

+1. It's extremely valuable to have a page summarizing the shooting range of the different libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏩ type: Enhancement Improve existing features 📄 type: Documentation Updates, fixes and additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.