Open abingham opened 4 months ago
Idea to fix problems like this:
ffmpeg_reader
should be very forgiving for out of bounds reads.
The enforcement of duration
should be in subclip()
. subclip()
could take a parameter elasticity
with the following values:
elasticity=='infinite'
:
ignores whether it's in bounds of the original duration.
result: new_clip.duration == end_time - start_time
elasticity=='strict'
:
assert original_clip.duration >= end_time - start_time
, plus a small epsilon to take floating-point error into account.
result: new_clip.duration == end_time - start_time
elasticity=='truncate'
:
truncate the ends so it fits in the old clip.
result: new_clip.duration <= end_time - start_time
elasticity=='truncatewarn'
:
same as truncate
, but does a warn()
if it truncates more than an epsilon.
The default should be truncatewarn
Something along these lines would work well for my purposes.
Just one minor issue: in the truncate
case, the new_clip.duration == min(original_clip.duration, end_time - start_time)
comparison doesn't seem correct. If my [start_time, end_time]
range overlaps the end of the data, then I'd expect new_clip.duration
to be original_clip.duration - start_time
which may be shorter than either of the arguments to min()
.
Something along these lines would work well for my purposes.
Just one minor issue: in the
truncate
case, thenew_clip.duration == min(original_clip.duration, end_time - start_time)
comparison doesn't seem correct. If my[start_time, end_time]
range overlaps the end of the data, then I'd expectnew_clip.duration
to beoriginal_clip.duration - start_time
which may be shorter than either of the arguments tomin()
.
Thanks, my formulation was wrong. corrected
This little program uses
subclip()
to take more than the available data in an input file, and then write the result to file:In the file writing phase I end up with an exception:
Expected Behavior
The ultimate problem with the program is that I'm trying to subclip more data than is available. So I would expect for
subclip()
to complain when I ask for the impossible.If it's actually the case that out-of-bounds
subclip()
calls are desirable, then I'd expect a more informative exception when the file writing eventually fails. That is, I'd like an error reporting the actual mistake I made (subclipping too much data) rather than some implementation detail (theOSError
above).Actual Behavior
As listed above, I get a relatively obscure and not terribly helpful exception when I do this. Here's the stack trace (trimmed to my call into
moviepy
code):Steps to Reproduce the Problem
Run the little program at the top, mutatis mutandis the filenames.
Specifications