Coder Social home page Coder Social logo

gitbib / pymkv2 Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 0.0 1.15 MB

A Python wrapper for mkvmerge. It provides support for muxing, splitting, linking, chapters, tags, and attachments through the use of mkvmerge.

Home Page: https://gitbib.github.io/pymkv2/

License: MIT License

Python 99.04% Makefile 0.96%
mkvmerge mkvtoolnix muxer

pymkv2's Introduction

pymkv2

PyPI Version License codecov versions

pymkv2 is a Python wrapper for mkvmerge and other tools in the MKVToolNix suite. It provides support for muxing, splitting, linking, chapters, tags, and attachments through the use of mkvmerge.

About pymkv2

it's a fork of the project. Pymkv2 is a Python 3 library for manipulating MKV files with mkvmerge. Constructing mkvmerge commands manually can quickly become confusing and complex. To remedy this, I decided to write this library to make mkvmerge more scriptable and easier to use. Please open new issues for any bugs you find, support is greatly appreciated!

Installation

mkvmerge must be installed on your computer, it is needed to process files when creating MKV objects. It is also recommended to add it to your $PATH variable but a different path can be manually specified. mkvmerge can be found and downloaded from here or from most package managers.

To install pymkv from PyPI, use the following command:

$ pip install pymkv2

You can also clone the repo and run the following command in the project root to install the source code as editable:

$ pip install -e .

Documentation

The documentation for pymkv can be found here or in the project's docstrings.

pymkv2's People

Contributors

gitbib avatar goldbergdata avatar joshuaavalon avatar rubo3 avatar sebitr avatar sheldonkwoodward avatar smahot avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pymkv2's Issues

mkvmerge_path str parameter can be limiting

Is your enhancement request related to a problem? Please describe.
Using the mkvmerge_path parameter (for example in verify_mkvmerge) can be limiting, if mkvmerge is not directly accessible and needs parameters to run.

One example would be flatpak run org.bunkus.mkvtoolnix-gui mkvmerge.

The subprocess function (in pymkv/Verifications.py line 20) would not accept this:
sp.check_output(['flatpak run org.bunkus.mkvtoolnix-gui mkvmerge', '-V']).decode()

It would be necessary to append to the list, to have something like that:
sp.check_output(['flatpak', 'run', 'org.bunkus.mkvtoolnix-gui', 'mkvmerge', '-V']).decode()

Describe the solution you'd like
It would be great to have a parameter with a list of strings for the mkvmerge path.
It could also be some sort of function to split the str into a list, which then gets appended to the subprocess function parameter.

Implementation steps

  • Find all functions with a mkvmerge_path parameter.
  • Replace/add a new parameter which would allow to use a list (or something similar).

Additional context

Poetry fails to install pymkv2 due to an issue detecting a valid version of iso-639

Describe the bug
Due to iso-639 being a dependency, I cannot add pymkv2 to my poetry project. There is a bug where iso-639 v0.4.5 cannot be detected by poetry.

To Reproduce

  1. Add pymkv2 to pyproject.toml
  2. Run poetry install

Expected behavior

Poetry should be able to install pymkv2 with no errors.

Screenshots

poetry-error

Software (please complete the following information):

  • OS: Windows 11 x64
  • MKVToolNix version: v86.0

Additional context

I would recommend using python-iso639 instead as its more up-to-date and will most likely work with poetry with no issues: https://pypi.org/project/python-iso639/

mux function could support a way to output its progress

Is your enhancement request related to a problem? Please describe.
When muxing something with mkvmerge it outputs the current progress in percent.
The current implementation of mux does not seem to support that information, which would be great to have, especially when running async or when muxing large files.

Describe the solution you'd like
Having an event function in the main object, which returns the progress, which is called when new progress information arrives.

Example:

mkv = MKVFile('/path/to/file.mkv')
mkv.remove_track(0)
mkv.mux('/path/to/output.mkv', gui.set_current_progress)

or

mkv = MKVFile('/path/to/file.mkv')
mkv.remove_track(0)
mkv.connect_event_new_progress(gui.set_current_progress)
mkv.mux('/path/to/output.mkv')

Implementation steps

  • Look at the output of mkvmerge and find a way to grab that information
  • Interpret that data
  • Add an event function which is called on new progress and returns that data
  • Add a variable to hold the connected function and a setter function to connect an external function to that event function

Additional context
I implemented something similar a few years ago, which still works, but the code is more a proof of concept, than a good implementation. It can be found here.
That function is used in combination with a gui progress bar.

Let me know, if you want help implementing this and the enhancement request from yesterday.

2.0.5: default mkvmerge_path regression

Describe the bug
MKVFile without specifying mkvmerge_path seems broken in 2.0.5.

To Reproduce
mkv = MKVFile(title=f'my_title')

Expected behavior
No error.

Screenshots

Traceback (most recent call last):
  File "C:\my_script.py", line 131, in <module>
    mkv = MKVFile(title=f'my_title')
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Python\Python312\site-packages\pymkv\MKVFile.py", line 111, in __init__
    if not verify_supported(file_path, mkvmerge_path=self.mkvmerge_path):
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Python\Python312\site-packages\pymkv\Verifications.py", line 187, in verify_supported
    file_path = verify_file_path_and_mkvmerge(file_path, mkvmerge_path)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Python\Python312\site-packages\pymkv\Verifications.py", line 135, in verify_file_path_and_mkvmerge
    return checking_file_path(file_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\me\AppData\Roaming\Python\Python312\site-packages\pymkv\Verifications.py", line 33, in checking_file_path
    raise TypeError(msg)
TypeError: "None" is not of type str

Software (please complete the following information):

  • OS: Windows 11 23H2
  • MKVToolNix version v85.0

Additional context
Does not occur in 2.0.4

Error: The file '--hearing-impaired-flag' could not be opened for reading: open file error.

I get this error message:

Error: The file '--hearing-impaired-flag' could not be opened for reading: open file error.

When trying to convert a video in Linux.

My setup is I have a Python Web App hosted in Azure. I develop it in Windows and it works on my machine. I get the encoded .mkv file. However when upload my app to Azure, I get this error message. Am I missing something here? Is there something different I need to setup for working on Linux? I have Chinese characters for naming my tracks:

mkv.add_track(MKVTrack(temp_srt_en.name, language="eng", track_name="English"))
mkv.add_track(MKVTrack(temp_srt_chs.name, language="chi", track_name="中文"))
mkv.add_track(MKVTrack(temp_srt_pinyin.name, language="chi", track_name="Pīnyīn"))

Don't know what the issue is exactly difficult to diagnose since I'm developing on a Windows box

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.