Git Product home page Git Product logo

mpv-matroska-crop's Introduction

mpv-matroska-crop

This is a script for mpv which automatically crops the video if the Matroska PixelCrop properties are set.

NOTE: Cropping does not work with hardware decoding. By default this script is only active when hardware decoding is disabled. See Dynamic control of hardware decoding for a workaround.

Installation

The only dependency is mkvmerge from mkvtoolnix.

Copy matroska_crop.lua into the scripts directory in your mpv config directory (defaults to ~/.config/mpv/ on Linux). If the directory doesn’t exist, create it.

Adding PixelCrop metadata

If you want to add the PixelCrop metadata to already existing Matroska files you can use the mkvpropedit tool (included in mkvtoolnix):

mkvpropedit video.mkv --edit track:v1 --set pixel-crop-top=120 --set pixel-crop-bottom=120

For further information please consult the man page of mkvpropedit and the output of mkvpropedit -l.

Dynamic control of hardware decoding

Since cropping is not available with hardware decoding, this script can be configured to only be active if a crop is defined in the media file.

For this behaviour to be active, create the file matroska_crop.conf in the script-opts directory in your mpv config directory and add the following contents:

dynamic_hwdec=yes

Please not the absence of spaces around the equal sign.

Known issues

  • It cannot crop the video while using hardware decoding (limitation of mpv)
  • It only works for local files (limitation of mkvmerge)
    This could be solved by mpv exposing the needed matroska metadata
  • Custom filters are not applied when the video has PixelCrop metadata (disable this script temporarily when you need to use custom filters).

mpv-matroska-crop's People

Contributors

sbruder 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.