Git Product home page Git Product logo

deriver-archive's Introduction

Why hello there my young friend 馃憢

路 TECHNOPHILE 路 OPTIMIST 路 CYCLIST 路 ARCHIVIST 路 DESIGN 路 VIDEO 路 TV 路 NOMAD 路 DOCKER 路 JAVASCRIPT 路

deriver-archive's People

Contributors

traceypooh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

deriver-archive's Issues

Thumbnail generation seems to be inefficient

As far as I can tell, the thumbnail generation code in Thumbnails.inc and Video.inc is inefficient, converting the whole video into frames as JPGs and then choosing frames out of those. This apparently can take a very long time (with the code allocating at minimum 1 hour and at least 1.5x the source video length for it). Additionally, it's inefficient, as in many cases the goal is to generate one frame every 30 seconds (and in items with a large number of videos, this gets reduced to two thumbnails per video). (I"m not 100% sure it actually creates every single frame, but the generated frame numbers makes me think it does. It might be that the -r argument specifying a lower framerate only dumps frames every so often, but it uses the input frame. At least it seems like it is decoding the whole video, which seems unneeded for thumbnails.)

FFMpeg supports a -ss argument to seek to a specific time. This takes a time duration, and more importantly "will be parsed using keyframes, which is very fast" (at least when used for the input). The seek time can just be a length in seconds (including a fractional part); for instance ffmpeg -ss 855.99 -i video.mp4 -vframes 1 test.jpg. Note that this was added around ffmpeg 2.1, which was released in 2013 or so, after this code was written.

Something like this could work (though it'd need modification, and it won't generate the same filenames as before, and I don't know PHP):

def generate_thumbnails(filename, frameLimit, frameEvery):
    # frameLimit is an int, frameEvery may be a float
    for i in range(frameLimit):
        subprocess.check_call("ffmpeg", "-ss", str(frameEvery * i), "-i", filename, "-vframes", "1", "thumbs/" + filename + "_" + str(i) + ".jpg")

This does run ffmpeg multiple times, rather than just once, but I think seeking will still be a lot faster.

I haven't actually tried this on my machine, so if this isn't actually a valid optimisation sorry for the inconvenience.

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.