Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use knowit to parse video metadata (frame_rate, duration, subtitles...) #1154

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

getzze
Copy link
Collaborator

@getzze getzze commented Jul 15, 2024

Using knowit has two advantages:

  • it can read the frame rate of the video (mkv or other) to be used to match subtitles and to convert frame-based subtitles to srt.
  • it gives more information about subtitle tracks than enzyme and it should find subtitles in .mov files.

In terms of dependency, it needs or ffmpeg or mediainfo installed, otherwise it fallbacks on using enzyme.
It's maintained by @ratoaq2 who used to maintain subliminal, so it fits very well :)

@getzze
Copy link
Collaborator Author

getzze commented Jul 15, 2024

test are failing on macos and windows because mediainfo is not installed detected (ratoaq2/knowit#180).

failing on python 3.12 because ratoaq2/knowit#176 is not merged yet.

@Diaoul
Copy link
Owner

Diaoul commented Jul 16, 2024

As long as there is no hard dependency to install ffmpeg or all those stuff, I'm fine with it!

💡 Might want to add those in the docker image as well

@getzze
Copy link
Collaborator Author

getzze commented Jul 16, 2024

knowit depends on pymediainfo, but it's a Python package. The libmediainfo library is bundled in the wheel package on Windows and MacOS. On Linux you need to install it manually. I should document it.

There is currently a bug in knowit so the bundled library is not automatically detected. It needs to be solved before it can be used in subliminal.

Might want to add those in the docker image as well

Good point, thanks

@Diaoul
Copy link
Owner

Diaoul commented Jul 16, 2024

I think this would make subliminal a non pure-python package now? That's OK, packaging is much easier nowadays with wheels and all.

But there might be some people running it on embedded platforms 😅

@getzze
Copy link
Collaborator Author

getzze commented Jul 16, 2024

If you don't have mediainfo, ffmpeg or mkvmerge external libraries installed, knowit falls back to enzyme. So external dependencies are completely optional.

Copy link

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  subliminal
  utils.py
  video.py
  subliminal/refiners
  metadata.py 90-95
Project Total  

This report was generated by python-coverage-comment-action

@getzze
Copy link
Collaborator Author

getzze commented Jul 25, 2024

Tests passing finally!

I opened a PR at pymediainfo to include the library on Linux and MacOS-arm64 (currently it's only bundled for Windows and MacOS-x86_64). So people would not have to install any external library to improve the parsing.

I think I should add a small paragraph to the docs (the one from the news fragment maybe). But I don't know where it would be best, any idea?

@nunotexbsd
Copy link

@getzze

For what I understand, kwowit will be a test depend?
If so, I will need to port it to FreeBSD then.

@getzze
Copy link
Collaborator Author

getzze commented Jul 26, 2024

knowit will be a mandatory dependency to subliminal, it's a python package.
It has 4 providers, 2 being completely external (non-python) soft dependencies, ffmpeg and mkvmerge; one provider is
pymediainfo, which is a python package, that is a wrapper for the external library libmediainfo. However pymediainfo wheel on Pypi has the library bundled (so you don't have to install it yourself), but only for Windows and old Mac. It's not possible to bundle it for FreeBSD. But it's still possible to install libmediainfo from the package manager. The python-pymediainfo package on Arch Linux has a dependency to libmediainfo for instance.

The last provider is the python package enzyme that was a dependency of subliminal. So even if no external tool is installed, it will still work as before (no improvement though).

@getzze getzze mentioned this pull request Jul 26, 2024
18 tasks
@getzze getzze linked an issue Sep 10, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Subtitle downloaded even when there are embedded subtitles
3 participants