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

Clip::subclip vs ffmpeg_extract_subclip? #235

Closed
achalddave opened this issue Dec 11, 2015 · 6 comments
Closed

Clip::subclip vs ffmpeg_extract_subclip? #235

achalddave opened this issue Dec 11, 2015 · 6 comments

Comments

@achalddave
Copy link
Contributor

It seems Clip::subclip is significantly slower than ffmpeg_extract_subclip. Is there a reason the former doesn't simply call the latter?

@Zulko
Copy link
Owner

Zulko commented Dec 11, 2015

clip.subclip is just a view of a clip. In moviepy the frames from a video file clip are decoded to raw (so that you can actually work with them) and then reencoded at write time.
The function ffmpeg_extract_subclip functions differently, it directly calls ffmpeg to make a new file that is a subclip of the former file. ffmpeg does not decode the frames if not necessary, which is why it is faster.

ffmpeg_extract_sublip does not decode the frame if it is not necessary. If you just need to extract

@achalddave
Copy link
Contributor Author

Ah I see. So I understand the difference in implementation, but it seems the output is pretty much the same - so shouldn't moviepy just use the faster implementation? Or are there cases where ffmpeg_extract_subclip won't work but Clip::subclip will?

Update: Immediately after I submitted this, I realized that Clip::subclip isn't necessarily based on a file. However, perhaps we could overwrite VideoFileClip::subclip with ffmpeg_extract_subclip?

@Zulko
Copy link
Owner

Zulko commented Dec 11, 2015

If you want to apply a filter, like "black and white" or "blur", you need to have the frames decoded, fo ffmpeg_extract_subclip won't do the trick.

@achalddave
Copy link
Contributor Author

Okay, I see, that makes sense. Perhaps we should add a note to VideoFileClip::subclip saying that users may want to look at ffmpeg_extract_subclip? But maybe others easily realized this - it just took me a while because I was trying to use Clip::subclip and then immediately write to disk, when ffmpeg_extract_subclip would be faster in that case.

At any rate, moviepy is super useful, thanks! I've been writing dumb helper functions to call ffmpeg for some time, and it's nice to no longer have to do that.

@Zulko
Copy link
Owner

Zulko commented Dec 11, 2015

Also have a look at imageio, it wraps ffmpeg and is "closer to the metal" than moviepy in some aspects.

@achalddave
Copy link
Contributor Author

Thanks! I think imageio may be a little too low level for my needs. I still think it would be neat to mention ffmpeg_extract_subclip in VideoFileClip::subclip documentation, and I can submit a PR if that's useful. Closing this issue for now.

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

2 participants