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

subclipping pre-subclipped video is setting the duration but not the frames #2304

Open
Implosiv3 opened this issue Dec 28, 2024 · 1 comment
Labels
bug Issues that report (apparent) bugs.

Comments

@Implosiv3
Copy link

Implosiv3 commented Dec 28, 2024

Imagine a simple video with fps = 30 and duration = 5.

You open it in moviepy and subclip it to only 1 second. Its new duration is 1 and you cannot do (obviously) .get_frame(t = 1) because first available frame is get_frame(t = 0) and last one is get_frame(t = 0.9666666666666667). But now you decide to do a subclip again, to 2 seconds. The system allows it, and the new duration if you print it is 2, but you still cannot do get_frame(t = 1).

If the clip is already subclipped, I think you wouldn't be able to subclip to a larger one. Or, if possible, you should be able to obtain those new frames, because the duration is the new one.
Pseudocode below

video     # video of 30 fps and 5s
print(video.duration)     # it says 5
video = video.subclipped(0, 1)     # video of 30fps and 1s
print(video.duration)      # it says 1
video.get_frame(t = 1)     # raises Exception
video = video.subclipped(0, 2)     # video of 30fps and 2s
print(video.duration)      # it says 2
video.get_frame(t = 1)     # raises Exception
@Implosiv3 Implosiv3 added the bug Issues that report (apparent) bugs. label Dec 28, 2024
@OsaAjani
Copy link
Collaborator

OsaAjani commented Jan 11, 2025

Hi, I actually cannot reproduce the exception, for me provided the original video is long enough no exception is raised. Could you check the issue still exists, and if so provide your initial video file ?

I would agree though that subclipping outside of theoretical duration should probably raise an exception, I have made a PR (#2319) implementing this behaviour, but I would like some others maintainers (@Zulko and @keikoro) input on that. Should we consider subclipping as intentionally able to break the current clip boundaries, due to the nature of how moviepy handle start and end time (virtual, applied at render time, not previously), or should we consider this a misleading behaviour (I vote in favour of the last) and merge the PR ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that report (apparent) bugs.
Projects
None yet
Development

No branches or pull requests

2 participants