Giter VIP home page Giter VIP logo

pymediainfo's Introduction

pymediainfo

image

image

image

image

image

This small package is a wrapper around the MediaInfo library.

It works on Linux, Mac OS X and Windows and is tested with Python 3.7 to 3.12 and PyPy3.

See https://pymediainfo.readthedocs.io/ for more information.

pymediainfo's People

Contributors

bgermann avatar jabbalaci avatar julienpalard avatar justin8 avatar koles46 avatar madebr avatar paltman avatar phill-85 avatar sbraz avatar tsitter-evertz avatar vslavik avatar wft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymediainfo's Issues

Seg Fault 11 on OS X

The line:

lib.MediaInfoA_Open(handle, filename.encode('utf-8'), 0)

throws a Seg Fault 11 on OS X.

I am having a hard time isolating the cause, and I am not familiar enough with C++ to understand the prototypes to know what is wrong with the arguments. Is this possibly related to the version of MediaInfo? I am on version 0.7.82

Seems could not parse images ?

I try to use this module to parse a image:

pymediainfo.MediaInfo('1409654674.jpg')

But it's not working.

mediainfo 1409654674.jpg

General
Complete name                            : 1409654674.jpg
Format                                   : JPEG
File size                                : 82.2 KiB

Image
Format                                   : JPEG
Width                                    : 1 079 pixels
Height                                   : 1 464 pixels
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 82.2 KiB (100%)

mediainfo could parse images, maybe this module does not wrapper image parser?

2.3.0 Build problem with setuptools-scm

I have problem build v2.3.0 for fedora
As I see it requires setuptools-scm now. And if is absent I have error

/usr/bin/python2 setup.py build '--executable=/usr/bin/python2 -s'
Download error on https://pypi.python.org/simple/setuptools_scm/: [Errno -2] Name or service not known -- Some packages may not be found!
Download error on https://pypi.python.org/simple/setuptools-scm/: [Errno -2] Name or service not known -- Some packages may not be found!
Couldn't find index page for 'setuptools_scm' (maybe misspelled?)
Download error on https://pypi.python.org/simple/: [Errno -2] Name or service not known -- Some packages may not be found!
No local packages or working download links found for setuptools_scm

https://kojipkgs.fedoraproject.org//work/tasks/3379/26973379/build.log

But if present I have another error:

/usr/bin/python2 setup.py build '--executable=/usr/bin/python2 -s'
Traceback (most recent call last):
  File "setup.py", line 35, in <module>
    "License :: OSI Approved :: MIT License",
  File "/usr/lib/python2.7/site-packages/setuptools/__init__.py", line 129, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python2.7/distutils/core.py", line 111, in setup
    _setup_distribution = dist = klass(attrs)
  File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 372, in __init__
    _Distribution.__init__(self, attrs)
  File "/usr/lib/python2.7/distutils/dist.py", line 287, in __init__
    self.finalize_options()
  File "/usr/lib/python2.7/site-packages/setuptools/dist.py", line 528, in finalize_options
    ep.load()(self, ep.name, value)
  File "/usr/lib/python2.7/site-packages/setuptools_scm/integration.py", line 22, in version_keyword
    dist.metadata.version = get_version(**value)
  File "/usr/lib/python2.7/site-packages/setuptools_scm/__init__.py", line 119, in get_version
    parsed_version = _do_parse(root, parse)
  File "/usr/lib/python2.7/site-packages/setuptools_scm/__init__.py", line 97, in _do_parse
    "use git+https://github.com/user/proj.git#egg=proj" % root)
LookupError: setuptools-scm was unable to detect version for '/builddir/build/BUILD/pymediainfo-2.3.0'.
Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.
For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj

https://kojipkgs.fedoraproject.org//work/tasks/3511/26973511/build.log

Build server don't have access to internet. I use tarball from github.

How can I solve this problem?

Error run tests during rpm package creation

How I must run test in rpm spec file?
If I use default ```%{__python2} setup.py test` I have an error

+ /usr/bin/python2 setup.py test
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: invalid command 'pytest'

Pathlib support

pymediainfo does not support Pathlib currently. It can be worked around by presenting the Pathlib object as a string, but since pymediainfo is all about accessing media file information it would make sense for the MediaInfo class to be able to accept a Pathlib object in its constructor.

Parsing fails after XPath change

It seems that commit e46f6db broke XML parsing for some users.
@choyj I'm opening this issue because I don't understand how the XPath change can cause things to fail for you, it's really weird.
Can you please run the following tests?

git clone https://github.com/sbraz/pymediainfo
cd pymediainfo
# move your example 10secfail.mp4 file here
python3 demo.py 10secfail.mp4

Does it work?

Then (still from the pymediainfo folder to make sure that you are loading the git version of the module, not another one):

python3 setup.py test

Do tests pass?

One last thing (still from the pymediainfo folder): I looked at that XML file which you generated and I can parse it without any problem, what happens if you do that?

python -c "import pymediainfo; print(pymediainfo.MediaInfo(open('10secfail.xml').read()).tracks)"

If it works, it will show you something like

[<Track track_id='None', track_type='General'>, <Track track_id='2', track_type='Video'>, <Track track_id='1', track_type='Audio'>]                                                                               

Different results with parse and Mediainfo(xml)

Using:

<?xml version="1.0" encoding="UTF-8"?>
<Mediainfo version="0.7.90">
<File>
<track type="General">
<Unique_ID>201687259218363082767350208093136514272 (0x97BB8D9E0E82DA3AB712EE412BBA6CE0)</Unique_ID>
<Complete_name>C:\htpc\upload1\Billions.S01E01.720p.WEB-DL-NTb_3\Billions.S01E01.720p.WEB-DL-NTb.mkv</Complete_name>
<Format>Matroska</Format>
<Format_version>Version 4 / Version 2</Format_version>
<File_size>707 MiB</File_size>
<Duration>54 min 21 s</Duration>
<Overall_bit_rate>1 819 kb/s</Overall_bit_rate>
<Encoded_date>UTC 2016-01-18 12:12:45</Encoded_date>
<Writing_application>mkvmerge v7.6.0 (&apos;Garden of Dreams&apos;) 64bit built on Feb  8 2015 13:04:34</Writing_application>
<Writing_library>libebml v1.3.1 + libmatroska v1.4.2</Writing_library>
</track>

<track type="Video">
<ID>1</ID>
<Format>AVC</Format>
<Format_Info>Advanced Video Codec</Format_Info>
<Format_profile>[email protected]</Format_profile>
<Format_settings__CABAC>Yes</Format_settings__CABAC>
<Format_settings__ReFrames>5 frames</Format_settings__ReFrames>
<Codec_ID>V_MPEG4/ISO/AVC</Codec_ID>
<Duration>54 min 21 s</Duration>
<Width>1 280 pixels</Width>
<Height>720 pixels</Height>
<Display_aspect_ratio>16:9</Display_aspect_ratio>
<Frame_rate_mode>Constant</Frame_rate_mode>
<Frame_rate>23.976 (24000/1001) FPS</Frame_rate>
<Color_space>YUV</Color_space>
<Chroma_subsampling>4:2:0</Chroma_subsampling>
<Bit_depth>8 bits</Bit_depth>
<Scan_type>Progressive</Scan_type>
<Default>Yes</Default>
<Forced>No</Forced>
</track>

<track type="Audio">
<ID>2</ID>
<Format>AAC</Format>
<Format_Info>Advanced Audio Codec</Format_Info>
<Format_profile>HE-AAC / LC</Format_profile>
<Codec_ID>A_AAC</Codec_ID>
<Duration>54 min 21 s</Duration>
<Channel_s_>2 channels</Channel_s_>
<Channel_positions>Front: L R</Channel_positions>
<Sampling_rate>48.0 kHz / 24.0 kHz</Sampling_rate>
<Frame_rate>23.438 FPS (1024 spf)</Frame_rate>
<Compression_mode>Lossy</Compression_mode>
<Language>English</Language>
<Default>Yes</Default>
<Forced>No</Forced>
</track>

<track type="Text">
<ID>3</ID>
<Format>UTF-8</Format>
<Codec_ID>S_TEXT/UTF8</Codec_ID>
<Codec_ID_Info>UTF-8 Plain Text</Codec_ID_Info>
<Language>English</Language>
<Default>Yes</Default>
<Forced>No</Forced>
</track>

</File>
</Mediainfo>

mi = MediaInfo(xml)
mi.to_data()

mi {'tracks': [{'writing_application': "mkvmerge v7.6.0 ('Garden of Dreams') 64bit built on Feb  8 2015 13:04:34", 'format_version': 'Version 4 / Version 2', 'format': 'Matroska', 'track_type': 'General', 'complete_name': 'C:\\htpc\\upload1\\Billions.S01E01.720p.WEB-DL-NTb_3\\Billions.S01E01.720p.WEB-DL-NTb.mkv', 'encoded_date': 'UTC 2016-01-18 12:12:45', 'file_size': '707 MiB', 'duration': '54 min 21 s', 'overall_bit_rate': '1 819 kb/s', 'unique_id': '201687259218363082767350208093136514272 (0x97BB8D9E0E82DA3AB712EE412BBA6CE0)', 'writing_library': 'libebml v1.3.1 + libmatroska v1.4.2'}, {'codec_id': 'V_MPEG4/ISO/AVC', 'color_space': 'YUV', 'format_info': 'Advanced Video Codec', 'frame_rate_mode': 'Constant', 'format': 'AVC', 'default': 'Yes', 'format_settings__cabac': 'Yes', 'track_type': 'Video', 'format_profile': '[email protected]', 'forced': 'No', 'track_id': '1', 'height': '720 pixels', 'width': '1 280 pixels', 'bit_depth': '8 bits', 'display_aspect_ratio': '16:9', 'frame_rate': '23.976 (24000/1001) FPS', 'chroma_subsampling': '4:2:0', 'scan_type': 'Progressive', 'duration': '54 min 21 s', 'format_settings__reframes': '5 frames'}, {'codec_id': 'A_AAC', 'forced': 'No', 'format_info': 'Advanced Audio Codec', 'channel_s': '2 channels', 'language': 'English', 'format': 'AAC', 'default': 'Yes', 'track_type': 'Audio', 'channel_positions': 'Front: L R', 'track_id': '2', 'duration': '54 min 21 s', 'format_profile': 'HE-AAC / LC', 'frame_rate': '23.438 FPS (1024 spf)', 'compression_mode': 'Lossy', 'sampling_rate': '48.0 kHz / 24.0 kHz'}, {'forced': 'No', 'language': 'English', 'format': 'UTF-8', 'default': 'Yes', 'track_type': 'Text', 'track_id': '3', 'codec_id_info': 'UTF-8 Plain Text', 'codec_id': 'S_TEXT/UTF8'}]}

mf = MediaInfo.parse(path_to_file)

mf.to_data()


mf {'tracks': [{'writing_application': "mkvmerge v7.6.0 ('Garden of Dreams') 64bit built on Feb  8 2015 13:04:34", 'other_file_size': ['707 MiB', '707 MiB', '707 MiB', '707 MiB', '707.3 MiB'], 'format_version': 'Version 4 / Version 2', 'file_name': 'Billions.S01E01.720p.WEB-DL-NTb', 'track_type': 'General', 'file_size': 741634835, 'text_codecs': 'UTF-8', 'other_unique_id': ['201687259218363082767350208093136514272 (0x97BB8D9E0E82DA3AB712EE412BBA6CE0)'], 'count_of_text_streams': '1', 'format_url': 'http://packs.matroska.org/', 'format_extensions_usually_used': 'mkv mk3d mka mks', 'count_of_video_streams': '1', 'duration': 3261910, 'writing_library': 'libebml v1.3.1 + libmatroska v1.4.2', 'video_format_withhint_list': 'AVC', 'audio_language_list': 'English', 'stream_identifier': '0', 'text_language_list': 'English', 'other_frame_rate': ['23.976 FPS'], 'video_language_list': 'English', 'file_creation_date': 'UTC 2016-01-18 12:17:40.000', 'text_format_list': 'UTF-8', 'codec': 'Matroska', 'complete_name': 'C:\\htpc\\upload1\\Billions.S01E01.720p.WEB-DL-NTb_3\\Billions.S01E01.720p.WEB-DL-NTb.mkv', 'other_writing_library': ['libebml v1.3.1 + libmatroska v1.4.2'], 'other_overall_bit_rate': ['1 819 kb/s'], 'file_last_modification_date__local': '2016-01-18 13:17:40.000', 'count_of_stream_of_this_kind': '1', 'other_kind_of_stream': ['General'], 'audio_format_withhint_list': 'AAC', 'other_codec': ['Matroska'], 'format': 'Matroska', 'kind_of_stream': 'General', 'other_format': ['Matroska'], 'file_last_modification_date': 'UTC 2016-01-18 12:17:40.000', 'overall_bit_rate': 1818897, 'folder_name': 'C:\\htpc\\upload1\\Billions.S01E01.720p.WEB-DL-NTb_3', 'frame_rate': '23.976', 'other_duration': ['54 min 21 s', '54 min 21 s 910 ms', '54 min 21 s', '00:54:21.910', '00:54:22;18', '00:54:21.910 (00:54:22;18)'], 'count': '322', 'video_format_list': 'AVC', 'file_extension': 'mkv', 'commercial_name': 'Matroska', 'audio_codecs': 'AAC LC-SBR', 'codecs_video': 'AVC', 'count_of_audio_streams': '1', 'file_creation_date__local': '2016-01-18 13:17:40.000', 'codec_extensions_usually_used': 'mkv mk3d mka mks', 'codec_url': 'http://packs.matroska.org/', 'audio_format_list': 'AAC', 'text_format_withhint_list': 'UTF-8', 'frame_count': '78208', 'other_writing_application': ["mkvmerge v7.6.0 ('Garden of Dreams') 64bit built on Feb  8 2015 13:04:34"], 'unique_id': 201687259218363082767350208093136514272L, 'encoded_date': 'UTC 2016-01-18 12:12:45'}, {'codec_settings': 'CABAC / 5 Ref Frames', 'other_interlacement': ['Progressive'], 'framerate_mode_original': 'VFR', 'sampled_height': '720', 'framerate_den': '1001', 'track_type': 'Video', 'framerate_num': '24000', 'interlacement': 'PPF', 'height': 720, 'format_settings__reframes': 5, 'codec_id_url': 'http://ffdshow-tryout.sourceforge.net/', 'format_url': 'http://developers.videolan.org/x264.html', 'other_resolution': ['8 bits'], 'duration': 3261929, 'unique_id': '17417841369823057563', 'codec_settings__cabac': 'Yes', 'other_track_id': ['1'], 'forced': 'No', 'stream_identifier': '0', 'codec_settings_refframes': '5', 'width': 1280, 'colorimetry': '4:2:0', 'other_delay': ['00:00:00.000'], 'sampled_width': '1280', 'track_id': 1, 'delay': 0, 'pixel_aspect_ratio': '1.000', 'other_bit_depth': ['8 bits'], 'other_height': ['720 pixels'], 'streamorder': '0', 'chroma_subsampling': '4:2:0', 'count_of_stream_of_this_kind': '1', 'other_kind_of_stream': ['Video'], 'codec': 'V_MPEG4/ISO/AVC', 'other_codec': ['AVC'], 'format_settings__cabac': 'Yes', 'other_frame_rate_mode': ['Constant'], 'color_space': 'YUV', 'kind_of_stream': 'Video', 'format': 'AVC', 'codec_info': 'Advanced Video Codec', 'other_format_settings__reframes': ['5 frames'], 'scan_type': 'Progressive', 'delay__origin': 'Container', 'internet_media_type': 'video/H264', 'format_info': 'Advanced Video Codec', 'display_aspect_ratio': '1.778', 'frame_rate': '23.976', 'codec_family': 'AVC', 'other_width': ['1 280 pixels'], 'format_settings': 'CABAC / 5 Ref Frames', 'other_duration': ['54 min 21 s', '54 min 21 s 929 ms', '54 min 21 s', '00:54:21.929', '00:54:22;18', '00:54:21.929 (00:54:22;18)'], 'count': '334', 'other_delay__origin': ['Container'], 'commercial_name': 'AVC', 'frame_rate_mode': 'CFR', 'other_scan_type': ['Progressive'], 'default': 'Yes', 'frame_count': '78208', 'other_forced': ['No'], 'other_default': ['Yes'], 'other_chroma_subsampling': ['4:2:0'], 'other_format_settings__cabac': ['Yes'], 'codec_profile': '[email protected]', 'codec_id': 'V_MPEG4/ISO/AVC', 'other_frame_rate': ['23.976 (24000/1001) FPS'], 'codec_url': 'http://ffdshow-tryout.sourceforge.net/', 'resolution': 8, 'bit_depth': 8, 'other_display_aspect_ratio': ['16:9'], 'format_profile': '[email protected]'}, {'format_settings__sbr': 'Yes (Implicit)', 'other_channel_s': ['2 channels'], 'track_type': 'Audio', 'other_channel_positions': ['2/0/0'], 'other_compression_mode': ['Lossy'], 'format_profile': 'HE-AAC / LC', 'duration': 3261910, 'samples_count': '156571680', 'forced': 'No', 'samples_per_frame': '1024', 'stream_identifier': '0', 'other_delay': ['00:00:00.000'], 'channel_positions': 'Front: L R', 'track_id': 2, 'delay': 0, 'codec': 'AAC LC-SBR', 'sampling_rate': '48000 / 24000', 'count_of_stream_of_this_kind': '1', 'other_kind_of_stream': ['Audio'], 'other_language': ['English', 'English', 'en', 'eng', 'en'], 'other_codec': ['AAC LC-SBR'], 'other_format_settings__sbr': ['Yes (Implicit)'], 'count': '272', 'other_video0_delay': ['00:00:00.000'], 'format': 'AAC', 'kind_of_stream': 'Audio', 'delay__origin': 'Container', 'format_info': 'Advanced Audio Codec', 'frame_rate': '23.438', 'delay_relative_to_video': 0, 'other_track_id': ['2'], 'other_duration': ['54 min 21 s', '54 min 21 s 910 ms', '54 min 21 s', '00:54:21.910', '00:54:21.910'], 'other_sampling_rate': ['48.0 kHz / 24.0 kHz'], 'other_delay__origin': ['Container'], 'commercial_name': 'AAC', 'channellayout': 'L R', 'language': 'en', 'default': 'Yes', 'other_delay_relative_to_video': ['00:00:00.000'], 'other_default': ['Yes'], 'channel_s': 2, 'streamorder': '1', 'codec_id': 'A_AAC', 'other_frame_rate': ['23.438 FPS (1024 spf)'], 'compression_mode': 'Lossy', 'codec_family': 'AAC', 'video0_delay': 0, 'other_forced': ['No'], 'unique_id': '11027699435699514785'}, {'track_type': 'Text', 'codec_id_info': 'UTF-8 Plain Text', 'forced': 'No', 'stream_identifier': '0', 'track_id': 3, 'codec': 'S_TEXT/UTF8', 'count_of_stream_of_this_kind': '1', 'other_kind_of_stream': ['Text'], 'other_language': ['English', 'English', 'en', 'eng', 'en'], 'other_codec': ['UTF-8'], 'kind_of_stream': 'Text', 'format': 'UTF-8', 'codec_info': 'UTF-8 Plain Text', 'other_track_id': ['3'], 'count': '234', 'commercial_name': 'UTF-8', 'language': 'en', 'default': 'Yes', 'other_forced': ['No'], 'other_default': ['Yes'], 'streamorder': '2', 'codec_id': 'S_TEXT/UTF8', 'unique_id': '13564175569453905064'}]}

Is this intended or a bug?

Cannot parse <->..</-> tags

I have a few files with data between <-></-> tags which upsets minidom. sample output from mediainfo is below:

/mnt/smbshare/Hilemusic/Jazz/Miles Davis/Sketches Of Spain/01 Concierto de Aranjuez (Adagio).m4a MPEG-4 Base Media / Version 2 mp42 27.9 MiB 16mn 23s 238 Kbps Sketches of Spain Miles Davis Concierto de Aranjuez (Adagio) 1 8 Miles Davis Jazz 1997 UTC 2009-12-13 09:41:30 UTC 2011-05-02 16:51:20 103 Yes <-> 0000014B 00000107 0000564D 0000B641 00049D0B 0007B384 00007FAC 000072E0 0007A21A 0007B4F8 780e3b08 1 AAC Advanced Audio Codec LC 40 16mn 23s Variable 234 Kbps 301 Kbps 2 channels Front: L R 44.1 KHz Lossy 27.5 MiB (98%) 1.3.3.0 1.3.3.0 -q 0.60 UTC 2009-12-13 09:41:30 UTC 2011-05-02 16:51:20

here is a quick and dirty fix:
4a5

import re
75c76

< dom = minidom.parseString(xml_data)

        dom = minidom.parseString(re.sub('<->[\\s\\d\\w]+</->', '', xml_data))

Cheers,
Paul

Broke on Windows

I've tried on Windows 7 and 10, lastest mediainfo installed and still it's broken here:
windll.MediaInfo from _get_library

I had to overload and manually load from installation path.

ValueError in MediaInfo.parse

It breaks on line lib.MediaInfoA_Open(handle, filename.encode("utf8"), 0) and says "Procedure probably called with too many arguments (4 bytes in excess)". I have just downloaded last version (0.7.84) of MediaInfo.
Quick look at sources of MI points me that API of dll is changed - function MediaInfoA_Open now takes only two arguments, so removing last argument in the call makes it work.

Python 3 issue

Thanks for this wrapper. It works well under Python 2 but under 3.x I got this error:

def to_data(self):
        data = {}
>       for k, v in self.__dict__.iteritems():
            if k != 'xml_dom_fragment':
           AttributeError: 'dict' object has no attribute 'iteritems'

I fixed it with the Six transition layer:

import six

def to_data(self):
    data = {}
    for k, v in six.iteritems(self.__dict__):
        if k != 'xml_dom_fragment':
            data[k] = v
    return data

For this I didn't write a pull request but tell me if you want one.

Failed to use on windows 10

hi, all
I have installed pymediainfo with command "pip install pymediainfo", and I got the information as follow:
Successfully built pymediainfo
Installing collected packages: pymediainfo
Successfully installed pymediainfo-2.2.0

so, it seems pymediainfo has been installed correctly. I wrote a very simple example to test it:
import pymediainfo
fileInfo = pymediainfo.MediaInfo.parse(r'D:\test.jpg')
...

then I got some errors as follow:

Traceback (most recent call last):
File "", line 1, in
File "D:\Anaconda3\lib\site-packages\pymediainfo_init_.py", line 176, in parse
lib = cls.get_library(library_file)
File "D:\Anaconda3\lib\site-packages\pymediainfo_init
.py", line 142, in get_library
return windll.MediaInfo
File "D:\Anaconda3\lib\ctypes_init
.py", line 417, in getattr
dll = self.dlltype(name)
File "D:\Anaconda3\lib\ctypes_init
.py", line 347, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

how can i fix this problem ? thanks very much :)

tracks only works in some cases, xml empty

mediainfo -f --Output=XML filename.webm works fine.
but since latest pip upgrade of pymediainfo from 1.4.0 to 2.0 finding that tracks information doesn't exist anymore. Well in fact dom is empty upon loading when it clearly isn't when running mediainfo.

Tried a different machine with 1.4.0 installed and worked on same file. Then upgraded using pip to 2.0 and found that same file fails.

Try downloading: http://peep.scss.tcd.ie/WebContent/corpus/dail_files/20080520_LCb/20080520_LCb.webm as a test case. Note, xmlwf shows XML from mediainfo is well-formed.

KeyError: 'type' occurs when handling some flv files

In a few flv files, when attempting to get tracks in the following code:

        m = MediaInfo.parse(filename)
        print(len(m.tracks))

I get the following exception:

Traceback (most recent call last):
  File "/mnt/d/ff/get_duration.py", line 20, in <module>
    get_duration('/mnt/z/bad_b1.flv')
  File "/mnt/d/ff/get_duration.py", line 6, in get_duration
    print(len(m.tracks))
  File "/usr/local/lib/python3.6/dist-packages/pymediainfo/__init__.py", line 258, in tracks
    self._populate_tracks()
  File "/usr/local/lib/python3.6/dist-packages/pymediainfo/__init__.py", line 241, in _populate_tracks
    self._tracks.append(Track(xml_track))
  File "/usr/local/lib/python3.6/dist-packages/pymediainfo/__init__.py", line 58, in __init__
    self.track_type = xml_dom_fragment.attrib['type']
KeyError: 'type'

My environment is Ubuntu 18.04 running in a WSL on Windows 10 using Python 3 and pymediainfo 2.3.0

I've attached two example xml files with this problem.
bad_b1.txt
bad_b2.txt

some values that have duplicate tags not being returned in tracks or to_json

$ pip2.7 freeze | grep pymed
pymediainfo==2.2.0

$ python2.7 -V
Python 2.7.9

$ mediainfo --version
MediaInfo Command line,
MediaInfoLib - v0.7.70

I was working out why the track.display_aspect_ratio from pymediainfo was returning 2.388 and the desktop mediainfo app was showing 2.40 : 1. I saw that the raw xml output from the library used by pymedianfo had both 2.388 and 2.40 : 1. The to_json also had only 2.388.

I have modified pymedinfo to allow it to return the raw xml after the file being parsed and then in my app using xmltodict to convert the raw xml into a dict so i can choose which value i want from multiple tags with the same name.

i.e. the output from xmltodict for u'Display_aspect_ratio' is
[u'2.388', u'2.40:1'],

simply i added:
self.xml = xml
under
def __init__(self, xml):

and at the bottom of the MediaInfo added

def raw_xml(self):
    return self.xml

Should I send a pull request?

Has anyone found this issue before and if so how was it solved?

some files don't show bitrate and stream_size

Hi,

First of all great library thanks!

I found that the library can't read the stream_size and bitrate of the video_stream of some files:

i.e. I have a a season with 20 episodes, everyone converted identically, for episode 1-11 and 13-21 it can read the bitrate and stream_size, but for episode 12 its just None.

Here's how I use your library to display the information:

media_info = MediaInfo.parse('<FILENAME>')
for track in media_info.tracks:
        track_infos = [];
        if track.track_type == 'General':
            table = 'containers'
            track_infos = ['complete_name', 'codec', 'count_of_audio_streams', 'count_of_video_streams', 'duration', 'file_extension', 'file_name', 'file_size', 'folder_name', 'format', 'overall_bit_rate']
        elif track.track_type == 'Video':
            table = 'video_streams'
            track_infos = ['bit_depth', 'bit_rate', 'codec_profile', 'commercial_name', 'encoded_library_name', 'encoding_settings', 'format', 'height', 'stream_size', 'number_of_frames', 'original_frame_rate', 'width']
        elif track.track_type == 'Audio':
            table = 'audio_streams'
            track_infos = ['bit_rate', 'codec', 'codec_id', 'commercial_name', 'compression_mode', 'duration', 'language', 'number_of_bytes', 'number_of_frames', 'sampling_rate', 'stream_size'];
        else:
            continue
        for track_info in track_infos:
            print(track.track_type)
            print (track_info + ": " + str(getattr(track, track_info)))

resulting in:

General
complete_name: /storage/sda/archiv/serien/Bones/Staffel 2/s02e012.mkv
General
codec: Matroska
General
count_of_audio_streams: 2
General
count_of_video_streams: 1
General
duration: 2638052
General
file_extension: mkv
General
file_name: s02e012
General
file_size: 134746795
General
folder_name: /storage/sda/archiv/serien/Bones/Staffel 2
General
format: Matroska
General
overall_bit_rate: 408625
Video
bit_depth: 8
Video
bit_rate: None
Video
codec_profile: [email protected]@Main
Video
commercial_name: HEVC
Video
encoded_library_name: x265
Video
encoding_settings: wpp / ctu=64 / min-cu-size=8 / max-tu-size=32 / tu-intra-depth=1 / tu-inter-depth=1 / me=1 / subme=2 / merange=57 / no-rect / no-amp / max-merge=2 / temporal-mvp / no-early-skip / rdpenalty=0 / no-tskip / no-tskip-fast / strong-intra-smoothing / no-lossless / no-cu-lossless / no-constrained-intra / no-fast-intra / open-gop / no-temporal-layers / interlace=0 / keyint=250 / min-keyint=23 / scenecut=40 / rc-lookahead=20 / lookahead-slices=0 / bframes=4 / bframe-bias=0 / b-adapt=2 / ref=3 / limit-refs=0 / weightp / no-weightb / aq-mode=1 / qg-size=32 / aq-strength=1.00 / cbqpoffs=0 / crqpoffs=0 / rd=3 / psy-rd=0.30 / rdoq-level=0 / psy-rdoq=0.00 / signhide / deblock / sao / no-sao-non-deblock / b-pyramid / cutree / rc=crf / crf=28.0 / qcomp=0.60 / qpmin=0 / qpmax=51 / qpstep=4 / ipratio=1.40 / pbratio=1.30
Video
format: HEVC
Video
height: 352
Video
stream_size: None
Video
number_of_frames: None
Video
original_frame_rate: None
Video
width: 624
Audio
bit_rate: None
Audio
codec: MPA1L3
Audio
codec_id: A_MPEG/L3
Audio
commercial_name: MPEG Audio
Audio
compression_mode: Lossy
Audio
duration: 2638052
Audio
language: None
Audio
number_of_bytes: None
Audio
number_of_frames: None
Audio
sampling_rate: 48000
Audio
stream_size: None
Audio
bit_rate: 128000
Audio
codec: MPA1L3
Audio
codec_id: A_MPEG/L3
Audio
commercial_name: MPEG Audio
Audio
compression_mode: Lossy
Audio
duration: 2710248
Audio
language: None
Audio
number_of_bytes: None
Audio
number_of_frames: None
Audio
sampling_rate: 48000
Audio
stream_size: 43363968

The tool mediainfo has the same issue, it can read the information for the other episodes but not this one.
I have a few other examples, but this one is the best to look into I guess, because of being part of a season with only one file not working...

Thanks for help!

*_language_list is not accurate

It appears that when a language is not defined, the *_language_list (audio_language_list, video_language_list, text_language_list) entries of the general track are not accurate. I've tested a file against MKVTooNix GUI, VLC, and MediaInfo GUI all of which have said languages are undetermined/undefined but in your tool in the general track, "English" will show up instead of "Undetermined"/"Undefined"

I am running on Ubuntu 14.04 and pymediainfo 2.2.1

How to determine libmediainfo is installed?

Currently, when libmediainfo is not installed, pymediainfo imports fine.
At parse time, an OSError is thrown when libmediainfo is not found.

Is there a portable (supported) way to determine pymediainfo is working as intended?
Depending on throwing an OSError that pymediainfo is not working is, in my opinion, not robust.

As a workaround, what I do now is:

import os.path
import pymediainfo # Succeeds since pymediainfo is installed

try:
    pymediainfo.MediaInfo.parse(os.path.realpath(__file__)
    libmediainfo_available = True
except OSError:
    libmediainfo_available = False

But I doubt this is kosher and supported.

cxfreeze can't find pymediainfo module?

I put pymediainfo name in cxfreeze's setup.py,but always show pkg_resources.DistributionNotFound: The 'pymediainfo' distribution was not found and is required by the application.
can you help me for this ? thank you so much

OSError loading libmediainfo.so with pymediainfo 2.0

I'm getting an error trying to use the latest version (I'm guessing it's related to #14 ?).

I don't see anything in the documentation about how libmediainfo needs to be installed, or if it matters what version.

>>> MediaInfo.parse(filename)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/var/www/httpd/sites/keep/keep-2.6.1/env/lib/python2.7/site-packages/pymediainfo/__init__.py", line 86, in parse
    lib = CDLL("libmediainfo.so.0")
  File "/opt/rh/python27/root/usr/lib64/python2.7/ctypes/__init__.py", line 360, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib64/libmediainfo.so.0: undefined symbol: _ZN6ZenLib6Ztring22Date_From_Seconds_1904Ej

This is on Red Hat Enterprise Linux Server release 6.7 (Santiago).

Mediainfo return empty list in flask when debug=True

I use pymediainfo 2.0 in mac and ubuntu ,I put a video in the same directory , wanna get it's information , this function works well in the main, but once I wanna use it in flask ,the function will return nothing , did I miss something?

# -*- coding: UTF-8 -*-

import sys
sys.path.append("./")
reload(sys)
sys.setdefaultencoding( "utf-8" )

import os

import time

from flask import Flask, render_template, request, redirect, url_for ,jsonify

from pymediainfo import MediaInfo

def t_media():
    print os.listdir('.')
    media_info = MediaInfo.parse('cisco.mp4')
    print media_info.tracks

    for track in media_info.tracks:
        if track.track_type == 'Video':
            Duration = track.duration
            print str(Duration/1000.0)+' sec'
    else:
        Duration = 'none'
    return Duration


app = Flask(__name__)

@app.route('/')
def index():
    return t_media()


if __name__ == '__main__':

    app.run(host='0.0.0.0',port=8080,debug=True)

it return 'none' in the web, and my Server cli got this:

# python test2.py
 * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
 * Restarting with stat
['.DS_Store', 'cisco.mp4', 'static', 'templates', 'test2.py', 'web.py']
[]
172.16.191.1 - - [01/Mar/2016 16:08:44] "GET / HTTP/1.1" 200 -

Handling of special Characters leads to exception

When having for example ä, ö, ü or & and some others are throwing a ctypes.ArgumentError: argument 2: <type 'exceptions.UnicodeDecodeError'>: 'ascii' codec can't decode byte 0xe2 in position 1: ordinal not in range(128)

Debian packaging in progress

Hi!

This is a friendly notice to let you know that Debian is working on packaging your software for Debian. You can follow the progress of that work in bug #867801 in the Debian Bug Tracking System (BTS).

The source code for the Debian package is in this git repository. It will be uploaded into Debian shortly, at which point it will end up in the NEW queue for legal review. Once the NEW process is completed, it takes about 10 days for the package to trickle down into "testing", which will become the next Debian release. This means your software will eventually be shipped in a "long term support" release, which last from three to five years, according to the current statistics.

If you are interested in maintaining the package yourself upstream, that is definitely possible. You can either upload the package yourself if you are a Debian member or I can act as a sponsor when a new release is published.

This is just a notification, but can also act as a coordination point for upstream packaging if you wish to followup on this. otherwise, feel free to close this issue whenever you like.

Why Track empty?

Hello! im trying to load this xml in pymediainfo class.
What is wrong with my XML?

code:

contentFile = None
pinFile="her.xml"
        try:
         with open(pinFile) as f:
               contentFile = f.read()
         except:
                print("something wrong")
if(contentFile):
        mediainfo = MediaInfo(contentFile)
        print(mediainfo.to_json())

output:
{"tracks": []}

<?xml version="1.0" encoding="UTF-8"?>
<Mediainfo version="0.7.70">
	<File>
		<track type="General">
			<Complete_name>her.mp4</Complete_name>
			<Format>MPEG-4</Format>
			<Format_profile>Base Media / Version 2</Format_profile>
			<Codec_ID>mp42</Codec_ID>
			<File_size>215 MiB</File_size>
			<Duration>2h 5mn</Duration>
			<Overall_bit_rate_mode>Variable</Overall_bit_rate_mode>
			<Overall_bit_rate>239 Kbps</Overall_bit_rate>
			<Movie_name>Her</Movie_name>
			<Genre>Romance</Genre>
			<ContentType>Short Film</ContentType>
			<Description>La película nos sitúa en un futuro no  muy lejano donde vive Theodore, un hombre solitario que trabaja como escritor y que está pasando por las últimas etapas de un traumático divorcio. La vida de Theodore no es demasiado emocionante, cuando no está tr...</Description>
			<Recorded_date>2013</Recorded_date>
			<Encoded_date>UTC 2017-06-06 19:38:45</Encoded_date>
			<Tagged_date>UTC 2017-06-07 16:41:03</Tagged_date>
			<Writing_application>HandBrake 1.0.1 2016122900</Writing_application>
			<Cover>Yes</Cover>
			<Comment>La película nos sitúa en un futuro no  muy lejano donde vive Theodore, un hombre solitario que trabaja como escritor y que está pasando por las últimas etapas de un traumático divorcio. La vida de Theodore no es demasiado emocionante, cuando no está tr...</Comment>
			<LongDescription>La película nos sitúa en un futuro no  muy lejano donde vive Theodore, un hombre solitario que trabaja como escritor y que está pasando por las últimas etapas de un traumático divorcio. La vida de Theodore no es demasiado emocionante, cuando no está trabajando se pasa las horas jugando a videojuegos y, de vez en cuando, sale con sus amigos. Pero todo va a cambiar cuando el escritor decide adquirir un nuevo sistema operativo para su teléfono y su ordenador, y este sistema tiene como nombre &quot;Samantha&quot;.</LongDescription>
			<AppleStoreCatalogID>152601</AppleStoreCatalogID>
			<ContentRating>mpaa|R|400|</ContentRating>
			<iTunMOVI dt="binary.base64">PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4gLyA8IURPQ1RZUEUgcGxpc3QgUFVCTElDICItLy9BcHBsZS8vRFREIFBMSVNUIDEuMC8vRU4iICJodHRwOi8vd3d3LmFwcGxlLmNvbS9EVERzL1Byb3BlcnR5TGlzdC0xLjAuZHRkIj4gLyA8cGxpc3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ZXk+IC8gCTxhcnJheT4gLyAJCTxkaWN0PiAvIAkJCTxrZXk+bmFtZTwva2V5PiAvIAkJCTxzdHJpbmc+U3Bpa2UgSm9uemU8L3N0cmluZz4gLyAJCTwvZGljdD4gLyAJPC9hcnJheT4gLyAJPGtleT5wcm9kdWNlcnM8L2tleT4gLyAJPGFycmF5PiAvIAkJPGRpY3Q+IC8gCQkJPGtleT5uYW1lPC9rZXk+IC8gCQkJPHN0cmluZz5NZWdhbiBFbGxpc29uPC9zdHJpbmc+IC8gCQk8L2RpY3Q+IC8gCQk8ZGljdD4gLyAJCQk8a2V5Pm5hbWU8L2tleT4gLyAJCQk8c3RyaW5nPlZpbmNlbnQgTGFuZGF5PC9zdHJpbmc+IC8gCQk8L2RpY3Q+IC8gCQk8ZGljdD4gLyAJCQk8a2V5Pm5hbWU8L2tleT4gLyAJCQk8c3RyaW5nPlNwaWtlIEpvbnplPC9zdHJpbmc+IC8gCQk8L2RpY3Q+IC8gCTwvYXJyYXk+IC8gCTxrZXk+c2NyZWVud3JpdGVyczwva2V5PiAvIAk8YXJyYXk+IC8gCQk8ZGljdD4gLyAJCQk8a2V5Pm5hbWU8L2tleT4gLyAJCQk8c3RyaW5nPlNwaWtlIEpvbnplPC9zdHJpbmc+IC8gCQk8L2RpY3Q+IC8gCTwvYXJyYXk+IC8gCTxrZXk+c3R1ZGlvPC9rZXk+IC8gCTxzdHJpbmc+QW5uYXB1cm5hIFBpY3R1cmVzPC9zdHJpbmc+IC8gPC9kaWN0PiAvIDwvcGxpc3Q+</iTunMOVI>
			<Keyword>Language:EN; Subtitles:ES</Keyword>
		</track>
		<track type="Video">
			<ID>1</ID>
			<Format>AVC</Format>
			<Format_Info>Advanced Video Codec</Format_Info>
			<Format_profile>[email protected]</Format_profile>
			<Format_settings__CABAC>No</Format_settings__CABAC>
			<Format_settings__ReFrames>3 frames</Format_settings__ReFrames>
			<Codec_ID>avc1</Codec_ID>
			<Codec_ID_Info>Advanced Video Coding</Codec_ID_Info>
			<Duration>2h 5mn</Duration>
			<Bit_rate>96.0 Kbps</Bit_rate>
			<Width>536 pixels</Width>
			<Height>288 pixels</Height>
			<Display_aspect_ratio>1.85:1</Display_aspect_ratio>
			<Original_display_aspect_ratio>1.85:1</Original_display_aspect_ratio>
			<Frame_rate_mode>Variable</Frame_rate_mode>
			<Frame_rate>23.976 fps</Frame_rate>
			<Minimum_frame_rate>23.974 fps</Minimum_frame_rate>
			<Maximum_frame_rate>23.981 fps</Maximum_frame_rate>
			<Color_space>YUV</Color_space>
			<Chroma_subsampling>4:2:0</Chroma_subsampling>
			<Bit_depth>8 bits</Bit_depth>
			<Scan_type>Progressive</Scan_type>
			<Bits__Pixel_Frame_>0.026</Bits__Pixel_Frame_>
			<Stream_size>86.4 MiB (40%)</Stream_size>
			<Encoded_date>UTC 2017-06-06 19:38:45</Encoded_date>
			<Tagged_date>UTC 2017-06-06 19:38:45</Tagged_date>
			<Color_primaries>BT.709</Color_primaries>
			<Transfer_characteristics>BT.709</Transfer_characteristics>
			<Matrix_coefficients>BT.709</Matrix_coefficients>
		</track>
		<track type="Audio">
			<ID>2</ID>
			<Format>AAC</Format>
			<Format_Info>Advanced Audio Codec</Format_Info>
			<Format_profile>LC</Format_profile>
			<Codec_ID>40</Codec_ID>
			<Duration>2h 5mn</Duration>
			<Bit_rate_mode>Variable</Bit_rate_mode>
			<Bit_rate>137 Kbps</Bit_rate>
			<Maximum_bit_rate>230 Kbps</Maximum_bit_rate>
			<Channel_s_>2 channels</Channel_s_>
			<Channel_positions>Front: L R</Channel_positions>
			<Sampling_rate>48.0 KHz</Sampling_rate>
			<Compression_mode>Lossy</Compression_mode>
			<Stream_size>123 MiB (57%)</Stream_size>
			<Title>Stereo</Title>
			<Language>English</Language>
			<Encoded_date>UTC 2017-06-06 19:38:45</Encoded_date>
			<Tagged_date>UTC 2017-06-06 19:38:45</Tagged_date>
		</track>
	</File>
</Mediainfo>

issue with mediainfo 17.10?

hi,
first, I just wanted to say that pymediainfo is the best! thanks for all your hard work! I'm not sure if I've discovered an issue, but I've found that some custom scripts designed to pull specific mediainfo values have stopped working with an upgrade to mediainfo version 17.10. If I roll back to 0.7.99_1, I don't seem to have the same problem. I'm on macOS El Capitan, and python 3.6.3.

The values I'm looking to pull are all in the General track, and with the switch everything is coming up as NoneType. I hope that's enough info; if I've missed anything, please let me know.

And thanks again!

Display text output like mediainfo

Ive been writing a function to convert all of the output to the == of Text output details - 0. Is there something already out there that does this?

Platform wheels

Is there a chance to get platform wheels for at least Windows and Mac with the bundled library file on PyPI? Would you accept a PR with continuous deployment that publishes them?

Problem with recent Fedora updates

Fedora now has version 17.10 of libmediainfo. It appears as if pymediainfo 2.2.0 is incompatible with it -- or is there some step I must now take to update the version I have installed with pip?

Thank you for your work! (I'm the author of Rapid Photo Downloader, which uses your wrapper).

empty xml if filename is in utf-8

Hi,

There seems to be an issue with filenames in utf-8

>>> from pymediainfo import MediaInfo
>>> media_info = MediaInfo.parse('Les shadoks - 4 - Quatrième série : BU-GA « Les Shadoks et le big blank » (2000).avi')
>>> len(media_info.tracks)
0
>>> media_info.to_data()
{'tracks': []}

When changing removing "env=environment" from the line 106 of pymediainfo/init.py

p = Popen(command, stdout=fp_out, stderr=fp_err)

it seems to work:

>>> from pymediainfo import MediaInfo
>>> media_info = MediaInfo.parse('Les shadoks - 4 - Quatrième série : BU-GA « Les Shadoks et le big blank » (2000).avi')
>>> len(media_info.tracks)
3
>>> media_info.to_data()
{'tracks': [{'writing_application': u'MEncoder 2:0.99+1.0pre7try2+cvs20060117-0ubuntu8', 'file_name': u'Les shadoks - 4 - Quatri\xe8me s\xe9rie : BU-GA \xab Les Shadoks et le big blank \xbb (2000)', ...}...]

ValueError: Procedure called with not enough arguments

Hello, I have some problem and don't know why. If I put the mediainfo.dll on the base dir where the script are that works well. But if I try get the .dll manually don't working.

media_info = MediaInfo.parse(
	file_mkv,
	library_file ='c:/mediaInfo/MediaInfo.dll'
	)

for track in media_info.tracks:
	if track.track_type == "Video":
		file_library.append(track.writing_library)

I get this error:
Python36-32\lib\site-packages\pymediainfo_init_.py", line 201, in parse
lib_version = lib.MediaInfo_Option(None, "Info_Version", "")
ValueError: Procedure called with not enough arguments (12 bytes missing) or wrong calling convention

OSError: [WinError 126] The specified module could not be found

I was using this module a month ago, idk what changed.

I'm running the demo.py

pymediainfo (2.2.0)
python 3.6.0
Win10

C:\Python36\python.exe C:/Users/James/Documents/_Github-Projects/MediaToVideo/MediaToVideo/GetMediaFiles/demo.py C:\Users\James\Pictures\pic.PNG
Traceback (most recent call last):
  File "C:/Users/James/Documents/_Github-Projects/MediaToVideo/MediaToVideo/GetMediaFiles/demo.py", line 44, in <module>
    process(sys.argv[1])
  File "C:/Users/James/Documents/_Github-Projects/MediaToVideo/MediaToVideo/GetMediaFiles/demo.py", line 25, in process
    media_info = MediaInfo.parse(fname)
  File "C:\Python36\lib\site-packages\pymediainfo\__init__.py", line 176, in parse
    lib = cls._get_library(library_file)
  File "C:\Python36\lib\site-packages\pymediainfo\__init__.py", line 142, in _get_library
    return windll.MediaInfo
  File "C:\Python36\lib\ctypes\__init__.py", line 414, in __getattr__
    dll = self._dlltype(name)
  File "C:\Python36\lib\ctypes\__init__.py", line 344, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

There is no way to use ParseSpeed when parsing file

PROBLEM: for now there is no way to specify ParseSpeed parameter for parsing using pymediainfo. The default value which mediainfo uses is 0.5 but for 4K HDR videos it may loose some important information, for example Text streams, whereas full parse (ParseSpeed=1.0) gives all the information about the video, including the text streams
EXPECTED: have an argument in parse method that allows to set the ParseSpeed that mediainfo will use, for example mediainfo.parse('/some/file.ts', parse_speed=1.0)
ACTUAL: There is no way to set the ParseSpeed using pymediainfo

File permission errors silently ignored

File permission issues just return an empty array instead of an error.

Took me longer than I care to admit to notice that the issue I had was a single video in a folder with 600 permissions and not owned by the same user.

When this occurs, open(file) returns PermissionError but MediaInfo.parse(file) returns a regular result with an empty tracks list.

This also happens when a file path does not exist or any other such issues.

Module not found problem

I installed the MediaInfo aplication from its source (https://mediaarea.net/en/MediaInfo) and installed the pymediainfo package using pip on python 2.7 on Windows 8.1. However, when I run the sample code of the pymedia page (https://pymediainfo.readthedocs.io/en/latest/index.html) I get this error message:

"Traceback (most recent call last):
File "C:\Users\Agusjacob96\Documents\video\New.py", line 2, in
media_info = MediaInfo.parse(r'C:\Users\Agusjacob96\Documents\video\C0.mov')
File "C:\Users\Agusjacob96\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymediainfo_init_.py", line 93, in parse
lib = cls.get_library()
File "C:\Users\Agusjacob96\AppData\Local\Programs\Python\Python36-32\lib\site-packages\pymediainfo_init
.py", line 76, in get_library
return windll.MediaInfo
File "C:\Users\Agusjacob96\AppData\Local\Programs\Python\Python36-32\lib\ctypes_init
.py", line 418, in getattr
dll = self.dlltype(name)
File "C:\Users\Agusjacob96\AppData\Local\Programs\Python\Python36-32\lib\ctypes_init
.py", line 348, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] No se puede encontrar el módulo especificado"

The code I'm using is the same, but I'm attaching it as well
test07.txt
Could you help me, please? I really need it! :(
Thanks :D

Encode problems on parse() function

Hi,

Having problems with files with quotes and specials chars like:

/home/dmartin/mounted/Multimedia/01-Incomming/2015-11-17_Instal·lació DUES TEXTIL/20151110_180916.mp4

Throws up:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 63: ordinal not in range(128)

Full Traceback:

Traceback (most recent call last):
  File "OrdenaIncomming.py", line 240, in <module>
    main()
  File "OrdenaIncomming.py", line 158, in main
    mi = MediaInfo.parse(os.path.join(root, arxiu))
  File "/usr/local/lib/python2.7/dist-packages/pymediainfo/__init__.py", line 92, in parse
    lib.MediaInfoA_Open(handle, filename.encode("utf8"), 0)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 63: ordinal not in range(128)

Mac OS X update breaks pymediainfo

Could have been the update to OS X 10.11.4 or an update of Command Line Tools (sorry I'm not sure which caused it). However, using CDLL no longer works.. This error results: OSError: dlopen libmediainfo.so.0, 6 cannot be found, so I guess Apple moved something. This exact happened after the upgrades on two separate Apple machines and the fix below worked for both.

To fix, I rolled back pymediainfo to v 1.4

XML Parser missing?

Hello, i've gotten pymediainfo to work fine on one machine but every other machine i try it on it gives me this error and i cannot figure out which parser is missing.

Traceback (most recent call last):
File "/usr/bin/mvandmake", line 253, in
main()
File "/usr/bin/mvandmake", line 250, in main
newfile = makeFile(todo + "/" + nfoname + ".mkv")
File "/usr/bin/mvandmake", line 125, in init
self.media_info = MediaInfo.parse(self.filename)
File "/usr/local/lib/python2.7/dist-packages/pymediainfo-1.3.6-py2.7.egg/pymediainfo/init.py", line 98, in parse
xml_dom = MediaInfo.parse_xml_data_into_dom(fp_out.read())
File "/usr/local/lib/python2.7/dist-packages/pymediainfo-1.3.6-py2.7.egg/pymediainfo/init.py", line 85, in parse_xml_data_into_dom
return BeautifulSoup(xml_data, "xml")
File "/usr/local/lib/python2.7/dist-packages/beautifulsoup4-4.3.1-py2.7.egg/bs4/init.py", line 152, in init
% ",".join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: xml. Do you need to install a parser library?

Segmentation fault in pymediainfo-2.1-py2.7 on ArchLinux

First of all I am very new to pymediainfo, so I apologize if I am not using this correctly or not providing enough information.

I built a script on Ubuntu 15.10 and it worked perfectly but I recently migrated to ArchLinux and I have been having issues pymediainfo crashing every time I try to parse a file.

My system is running both Python3 and Python2.7, but my script is written in 2.7 so I have used pip2 to install pymediainfo.

When I run the code mentioned below in Python3 it works without any issues, I am trying to see what am I doing wrong in Python2.7

I am running pymediainfo-2.1.
SystemInfo
Linux 4.5.1-1-ARCH #1 SMP PREEMPT Thu Apr 14 19:19:32 CEST 2016 x86_64 GNU/Linux

from pymediainfo import MediaInfo
MediaInfo.parse('/mnt/Media/Movies/Moonwalkers.2015.BR-Rip.AC3.-FGT.mkv')

I have verified I have full permissions on the file in question.

Appreciate the help!

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.