Giter VIP home page Giter VIP logo

Comments (3)

bzczb avatar bzczb commented on June 3, 2024

Idea to fix problems like this:

ffmpeg_reader should be very forgiving for out of bounds reads.

  • for video, reads before the start get the first frame, reads after the end get the last frame
  • for audio, out-of-bounds reads get 0-samples

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

from moviepy.

abingham avatar abingham commented on June 3, 2024

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().

from moviepy.

bzczb avatar bzczb commented on June 3, 2024

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().

Thanks, my formulation was wrong. corrected

from moviepy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.