Giter VIP home page Giter VIP logo

Comments (7)

sbraz avatar sbraz commented on May 23, 2024 2

I can reproduce with Ubuntu 18!

from pymediainfo.

choyj avatar choyj commented on May 23, 2024

So tried all of these. A few comments:

  • python3 demo.py 10secfail.mp4 doesn't appear to do anything for me.
  • I couldn't get python3 setup.py test to work. It had trouble finding pytest, but running pytest manually worked.
  • When I first started debugging unicode issue, I always found it weird that I could save the OLDXML output to a file MediaInfo(open()) would work, but MediaInfo.parse() would not.
  • Good files fail with no tracks with what's currently in master due to the File/ you added. Removing it works for me.
    Attached is the output from my run
    output.txt

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

There is a problem with libmediainfo on Ubuntu 18. The XML output from my code looks like this:

<File>                         
<track type="General">                          
…

Whereas If I run mediainfo --output=OLDXML, the header is present:

<?xml version="1.0" encoding="UTF-8"?>
<Mediainfo version="17.12">
<File>
<track type="General">
…    

@JeromeMartinez do you have any Idea why this happens? I've run the tests with Ubuntu 18's libmediainfo0v5:amd64 version 17.12-1build1.
This is my code, am I missing an option?

def parse(cls, filename, library_file=None, cover_data=False,
encoding_errors="strict"):
"""
Analyze a media file using libmediainfo.
If libmediainfo is located in a non-standard location, the `library_file` parameter can be used:
>>> pymediainfo.MediaInfo.parse("tests/data/sample.mkv",
... library_file="/path/to/libmediainfo.dylib")
:param filename: path to the media file which will be analyzed.
:param str library_file: path to the libmediainfo library, this should only be used if the library cannot be auto-detected.
:param bool cover_data: whether to retrieve cover data as base64.
:param str encoding_errors: option to pass to :func:`str.encode`'s `errors`
parameter before parsing MediaInfo's XML output.
:type filename: str or pathlib.Path
:rtype: MediaInfo
"""
lib = cls._get_library(library_file)
if pathlib is not None and isinstance(filename, pathlib.PurePath):
filename = str(filename)
else:
url = urlparse.urlparse(filename)
# Test whether the filename is actually a URL
if url.scheme is None:
# Test whether the file is readable
with open(filename, "rb"):
pass
# Define arguments and return types
lib.MediaInfo_Inform.restype = c_wchar_p
lib.MediaInfo_New.argtypes = []
lib.MediaInfo_New.restype = c_void_p
lib.MediaInfo_Option.argtypes = [c_void_p, c_wchar_p, c_wchar_p]
lib.MediaInfo_Option.restype = c_wchar_p
lib.MediaInfo_Inform.argtypes = [c_void_p, c_size_t]
lib.MediaInfo_Inform.restype = c_wchar_p
lib.MediaInfo_Open.argtypes = [c_void_p, c_wchar_p]
lib.MediaInfo_Open.restype = c_size_t
lib.MediaInfo_Delete.argtypes = [c_void_p]
lib.MediaInfo_Delete.restype = None
lib.MediaInfo_Close.argtypes = [c_void_p]
lib.MediaInfo_Close.restype = None
# Obtain the library version
lib_version = lib.MediaInfo_Option(None, "Info_Version", "")
lib_version = tuple(int(_) for _ in re.search("^MediaInfoLib - v(\S+)", lib_version).group(1).split("."))
# The XML option was renamed starting with version 17.10
if lib_version >= (17, 10):
xml_option = "OLDXML"
else:
xml_option = "XML"
# Cover_Data is not extracted by default since version 18.03
# See https://github.com/MediaArea/MediaInfoLib/commit/d8fd88a1c282d1c09388c55ee0b46029e7330690
if cover_data and lib_version >= (18, 3):
lib.MediaInfo_Option(None, "Cover_Data", "base64")
# Create a MediaInfo handle
handle = lib.MediaInfo_New()
lib.MediaInfo_Option(handle, "CharSet", "UTF-8")
# Fix for https://github.com/sbraz/pymediainfo/issues/22
# Python 2 does not change LC_CTYPE
# at startup: https://bugs.python.org/issue6203
if (sys.version_info < (3,) and os.name == "posix"
and locale.getlocale() == (None, None)):
locale.setlocale(locale.LC_CTYPE, locale.getdefaultlocale())
lib.MediaInfo_Option(None, "Inform", xml_option)
lib.MediaInfo_Option(None, "Complete", "1")
lib.MediaInfo_Open(handle, filename)
xml = lib.MediaInfo_Inform(handle, 0)
# Delete the handle
lib.MediaInfo_Close(handle)
lib.MediaInfo_Delete(handle)
return cls(xml, encoding_errors)

from pymediainfo.

choyj avatar choyj commented on May 23, 2024

More work for you to create an Ubuntu 18 VM, but great news you were able to reproduce it!

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

I've bisected libmediainfo to find the point where this changed. Apparently, the MediaInfo XML tag was never present before MediaArea/MediaInfoLib@575a9a3 (which means v18.0.3). The reason it was present with --output=OLDXML for the CLI version is that the header was present in the MediaInfoList objects and I guess the CLI version uses this (because it is used to parse multiple files at once).

I'm going to fix pymediainfo so that it can work with the XML output from older versions, this shouldn't be too complex.

from pymediainfo.

JeromeMartinez avatar JeromeMartinez commented on May 23, 2024

@JeromeMartinez do you have any Idea why this happens?

I was not fast enough :), you found that this is already fixed.

from pymediainfo.

Related Issues (20)

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.