-
Notifications
You must be signed in to change notification settings - Fork 12
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
Use with x.get_frame
instead of x.get_frame
globally
#171
base: master
Are you sure you want to change the base?
Changes from 2 commits
2d6227f
586b642
e6daf9b
b698ef0
598b737
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,10 +169,12 @@ def clear_cache() -> None: | |
try: | ||
for output in get_outputs().values(): | ||
if isinstance(output, VideoOutputTuple): | ||
output.clip.get_frame(0) | ||
with output.clip.get_frame(0): | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing, though I found out this is apparantly valid if isinstance(output, VideoOutputTuple):
output.clip.get_frame(0).close()
break There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The (typical) problem with not using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There’s nothing between the get_frame call and the close call, so no opportunities for other exceptions. If get_frame throws, there’s nothing to be closed. If it succeeds, you immediately close it anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ironically, I believe this is actually safer than a |
||
break | ||
except Exception: | ||
core.std.BlankClip().get_frame(0) | ||
with core.std.BlankClip().get_frame(0): | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if applicable here. What even is the purpose of getting (and immediately discarding) a blank clip's first frame? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure. Figuring out why and whether there's a better method is out of the scope of this PR though imo There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function modifies VapourSynth’s cache limit, so perhaps this is just an arbitrary VapourSynth call to trigger an actual cache update. |
||
core.max_cache_size = cache_size | ||
except Exception: | ||
... | ||
|
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.
Considering this is already inside a
try
block, it might be cleaner to use an explicitfinally
instead?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.
This doesn't work as suggested. Works if I do something like this instead, though:
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.
oh, whoops. yeah, that's true
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.
Yes,
close
needs to be on the returned frame, not the clip.But: the adjusted snippet fails if
get_frame
actually throws, because then the assignment never happens.