-
Notifications
You must be signed in to change notification settings - Fork 4
Add the ability to specify ffmpeg path & use Matplotlib's ffmpeg path #39
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
Open
calw20
wants to merge
17
commits into
ali-ramadhan:main
Choose a base branch
from
calw20:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
9c9fe30
Add the ability to specify ffmpeg path & use MatPlotLib's ffmpeg path
calw20 2cc30df
Add mutli-thread check to the init warning.
calw20 d6ef509
Whitelist file extensions and do check
calw20 de8df6b
Quick check to make sure frame counter is never None
calw20 d28281d
Add checks to make sure Scale Filters are valid
calw20 53d7e19
Fix badly placed assert
calw20 b1723a7
Apply formatting suggestion from @ali-ramadhan
calw20 aa71fbe
Make default path more clear
calw20 cbfafd8
Add optional path fallback & warning to ffmpeg path provider
calw20 44c2b23
Make the default ffmpeg path one that is sync'd across multi-processes
calw20 a65301b
Fix bug where default path isn't used if an override path isn't provided
calw20 d6e7a32
Add example of overloading matplotlibs ffmpeg rcPrams setting with a …
calw20 1ec77f7
Remove Limits on Filetype
calw20 b18707d
Move custom ffmpeg example to 'custom_ffmpeg_sine_wave.py'
calw20 f6f9fff
Make \self.ffmpeg_path\ be a path object
calw20 df66f64
Make \loom._get_scale_filter\ return the accepted scale options on er…
calw20 b557689
Add some simple docs about providing a custom FFmpeg path
calw20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| from joblib import Parallel, delayed | ||
|
|
||
| # Either the environ var OR matplotlib rcPram *needs* to be set BEFORE | ||
| # importing matplotloom | ||
| import imageio_ffmpeg # python library that provides ffmpeg binary | ||
| FFMPEG_PATH: str = imageio_ffmpeg.get_ffmpeg_exe() | ||
|
|
||
| # Configure matplotlib rcPrams, if your global / project rcPrams file | ||
| # already sets this then you don't need to overload it. | ||
| plt.rcParams['animation.ffmpeg_path'] = FFMPEG_PATH | ||
|
|
||
| # Alternatively could set the environment variable however this *does not* | ||
| # inform matplotlib there is a valid ffmpeg binary so should be avoided. | ||
| # The intention is to allow any more complex toolchains the option if needed. | ||
| # import os | ||
| #os.environ["LOOM_FFMPEG_PATH"] = FFMPEG_PATH | ||
|
|
||
| from matplotloom import Loom | ||
|
|
||
| def plot_frame(phase, frame_number, loom): | ||
| fig, ax = plt.subplots() | ||
|
|
||
| x = np.linspace(0, 2*np.pi, 200) | ||
| y = np.sin(x + phase) | ||
|
|
||
| ax.plot(x, y) | ||
| ax.set_xlim(0, 2*np.pi) | ||
|
|
||
| loom.save_frame(fig, frame_number) | ||
|
|
||
| with Loom("custom_parallel_sine_wave.gif", fps=30, parallel=True) as loom: | ||
| phases = np.linspace(0, 2*np.pi, 100) | ||
|
|
||
| Parallel(n_jobs=-1)( | ||
| delayed(plot_frame)(phase, i, loom) | ||
| for i, phase in enumerate(phases) | ||
| ) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should the user-supplied
ffmpeg_pathbe an input here? I guess it can't be since this is__init__.py. I guess in the instance that ffmpeg is not available on the system but the user-supplied path works this will still produce a warning, but maybe this is fine?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.
Yeah that was my thought as well but then I saw it was passed to
__init__.pyI couldn't figure out a way to make it stick. The hope was that by using matplotlib's rcPrams if a user updated the rcPrams before importingLoomit would pull the updated value.This works but only in the context of the main thread, as soon as you parallelise
Loomit re-imports matplotlib & its rcPrams seems to be reset to the file-based defaults. I'm yet to test it but in theory if you add an rcPrams file where matplotlib expects it those settings should be maintained in the mutli-threaded/process context.