Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.
/ mpv-matroska-crop Public archive

A script for mpv which automatically crops the video if the Matroska PixelCrop properties are set.

License

Notifications You must be signed in to change notification settings

sbruder/mpv-matroska-crop

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

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

About

A script for mpv which automatically crops the video if the Matroska PixelCrop properties are set.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages