Giter Site home page Giter Site logo

mpdecimate_trim's Introduction

Script to trim similar/duplicate fragments from video clips. While keeping audio in sync.

Note that it does not do what is often called "dropping frames" (i.e. removing them from container by replacing with PTS of a "similar enough" one from another part of the clip). It actually gets rid of them completely, making the resulting clip shorter in time.

Note also that some variables, such as mpdecimate thresholds or output codec settings, are currently hardcoded in the script. Mostly due to laziness ;-).

Usage

Needs Python3.7+ and ffmpeg.

$ mpdecimate_trim.py [--skip SKIP] [--keep] [--vaapi <render_device_filepath>] [--vaapi-decimate [render_device_filepath]] <filepath>

This will take file at <filepath>, detect frames with certain similarity, re-encode it with them removed (using libx265/hevc_vaapi) and delete the original file.

The --keep switch makes it keep the original.

By default, re-encode happens even if no fragments to trim are found. This can be adjusted by setting --skip to minimum amount of remaining clip parts (e.g. <=1 is equivalent to default, 2 means 1 trimmed fragment, and so on).

The --vaapi option enables VA-API based hardware accelerated transcoding. Note that the script does not check whether supplied input and/or available GPU are capable of performing the transcode, if they are not the process will fail.

The --vaapi-decimate option enables VA-API based hardware accelerated decimate filter. If the optional device path is supplied, this device will be used. Otherwise, it will attempt to use device specified with --vaapi option. If neither device is specified, the script will fail. Note that on some older versions of ffmpeg this might fail even if VA-API transcoding works, not sure why. I have only tested this with >=4.4.1.

vs_decimate?

Was a different experiment, using vapoursynth. Abandoned, because its' decimation algorithm does not fit my needs, and the whole process is also noticeably slower.

In case you want to use it for something, it needs Python3.6+ and vapoursynth with ffms2 and damb.

mpdecimate_trim's People

Contributors

kenjitakahashi avatar

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.