Giter VIP home page Giter VIP logo

Comments (30)

sbraz avatar sbraz commented on May 23, 2024 2

OK you've convinced me: that mapping thing is horrible. I'm going to add an option to parse or a new function to make it return text.

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024 1

i went with a cleaned up version of above (iterating keys instead of calling them explicitly). Ive never been a fan of changing source code as it breaks upstream development updates without human eyes so no ci/cd. @PyR8zdl i can repaste the updated code i wrote if you want it, and @sbraz if you could be convinced, adding a helper function to remove that would be pretty nifty

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024 1

@PyR8zdl The mappings are every key used in details - 0. The only "difference" is there is a duplicate key in audio (i think). I just havent cleaned it up as it didnt effect the parsing. This also accounts for situations where other_ isnt available as expected and grabs the regular output.

def format_mediainfo(mediainfo):
    media_info = []
    tracks = mediainfo.to_data()['tracks']
    for track in tracks:
        track_type = track['track_type']
        if int(track['count_of_stream_of_this_kind']) > 1:
            media_info.append(f'{track_type} #{int(track["stream_identifier"]) + 1}')
        else:
            media_info.append(track_type)
        for k, v in track.items():
            if k in key_mappings:
                if 'other' in k:
                    media_info.append(formatted(key_mappings[k], track[k][0]))
                else:
                    media_info.append(formatted(key_mappings[k], track[k]))
            elif k.strip('other_') in key_mappings:
                media_info.append(formatted(key_mappings[k.strip('other_')], track[k]))
            elif k[:1].isdigit():
                media_info.append(formatted((k[:8] + '.' + k[8:]).replace('_', ':'), v))
        media_info.append('')

    return '\n'.join(media_info)


def formatted(left, right):
    fixed = f"{left:<41}: {right}"
    return fixed


key_mappings = {
    "other_unique_id": "Unique ID",
    "file_name": "Complete name",
    "other_format": "Format",
    "format_version": "Format version",
    "other_file_size": "File size",
    "other_overall_bit_rate": "Overall bit rate",
    "movie_name": "Movie name",
    "encoded_date": "Encoded date",
    "other_writing_application": "Writing application",
    "format_profile": "Format profile",
    "format_settings": "Format settings",
    "other_format_settings__cabac": "Format settings, CABAC",
    "other_format_settings__reframes": "Format settings, RefFrames",
    "other_width": "Width",
    "other_height": "Height",
    "other_display_aspect_ratio": "Display aspect ratio",
    "other_frame_rate_mode": "Frame rate mode",
    "color_space": "Color space",
    "other_chroma_subsampling": "Chroma subsampling",
    "other_scan_type": "Scan type",
    "bits__pixel_frame": "Bits/(Pixel*Frame)",
    "other_writing_library": "Writing library",
    "encoding_settings": "Encoding settings",
    "color_range": "Color range",
    "color_primaries": "Color primaries",
    "matrix_coefficients": "Matrix coefficients",
    "format_info": "Format/Info",
    'other_overall_bit_rate_mode': "Overall bit rate mode",
    "other_bit_rate_mode": "Bit rate mode",
    "other_channel_s": "Channel(s)",
    "channel_positions": "Channel positions",
    "channel_layout": "Channel layout",
    "other_sampling_rate": "Sampling rate",
    "other_commercial_name": "Commercial name",
    "other_frame_rate": "Frame rate",
    "other_bit_depth": "Bit depth",
    "other_compression_mode": "Compression mode",
    "other_service_kind": "Service kind",
    "track_id": "ID",
    "codec_id": "Codec ID",
    "codec_id_info": "Codec ID/Info",
    "other_duration": "Duration",
    "other_bit_rate": "Bit rate",
    "count_of_elements": "Count of elements",
    "other_stream_size": "Stream size",
    "other_language": "Language",
    "other_default": "Default",
    "other_forced": "Forced",
    "muxing_mode": "Muxing mode"
}

from pymediainfo.

PyR8zdl avatar PyR8zdl commented on May 23, 2024 1

@sbraz That would be ideal. Thanks!

And thanks @dirtycajunrice for the workaround!

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024 1

@sbraz hahahaha i agree. it is a lot of code for no reason :P thank you for coming to the dark side

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024 1

Please try the updated text branch now with full=False.

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

Well.. in case there isnt:

def formatted(left, right):
    fixed = f"{left}{'':32}: {right}"
    return fixed

def format_mediainfo(mediainfo):
    media_info = []
    tracks = mediainfo.to_data()['tracks']
    for track in tracks:
        track_type = track['track_type']
        if track['count_of_stream_of_this_kind'] > 1:
            media_info.append(f'{track_type} #{int(track["stream_identifier"]) + 1}')
        else:
            media_info.append(track_type)
        if track_type == "General":
            media_info.append(formatted('Unique ID', track["other_unique_id"][0]))
            media_info.append(formatted('Complete name', f'{track["file_name"]}.{track["file_extension"]}'))
            media_info.append(formatted('Format', track['other_format'][0]))
            media_info.append(formatted('Format version', track['format_version']))
            media_info.append(formatted('File size', track['other_file_size'][0]))
            media_info.append(formatted('Duration', track['other_duration'][0]))
            media_info.append(formatted('Overall bit rate', track['other_overall_bit_rate'][0]))
            media_info.append(formatted('Movie name', track['movie_name']))
            media_info.append(formatted('Encoded date', track['encoded_date']))
            media_info.append(formatted('Writing application', track['other_writing_application'][0]))
            media_info.append(formatted('Writing library', track['other_writing_library'][0]))
            media_info.append('')
        elif track_type == "Video":
            media_info.append(formatted('ID', track['track_id']))
            media_info.append(formatted('Format', track['format']))
            media_info.append(formatted('Format/Info', track['format_info']))
            media_info.append(formatted('Format profile', track['format_profile']))
            media_info.append(formatted('Format settings', track['format_settings']))
            media_info.append(formatted('Format settings, CABAC', track['other_format_settings__cabac'][0]))
            media_info.append(formatted('Format settings, ReFrames', track['other_format_settings__reframes'][0]))
            media_info.append(formatted('Codec ID', track['codec_id']))
            media_info.append(formatted('Duration', track['other_duration'][0]))
            media_info.append(formatted('Bit rate', track['other_bit_rate'][0]))
            media_info.append(formatted('Width', track['other_width'][0]))
            media_info.append(formatted('Height', track['other_height'][0]))
            media_info.append(formatted('Display aspect ratio', track['other_display_aspect_ratio'][0]))
            media_info.append(formatted('Frame rate mode', track['other_frame_rate_mode'][0]))
            media_info.append(formatted('Frame rate', track['other_frame_rate'][0]))
            media_info.append(formatted('Color space', track['color_space']))
            media_info.append(formatted('Chroma subsampling', track['other_chroma_subsampling'][0]))
            media_info.append(formatted('Bit depth', track['other_bit_depth'][0]))
            media_info.append(formatted('Scan type', track['other_scan_type'][0]))
            media_info.append(formatted('Bits/(Pixel*Frame)', track['bits__pixel_frame']))
            media_info.append(formatted('Stream size', track['other_stream_size'][0]))
            media_info.append(formatted('Writing library', track['other_writing_library'][0]))
            media_info.append(formatted('Encoding settings', track['encoding_settings']))
            media_info.append(formatted('Language', track['other_language'][0]))
            media_info.append(formatted('Default', track['other_default'][0]))
            media_info.append(formatted('Forced', track['other_forced'][0]))
            media_info.append(formatted('Color range', track['color_range']))
            media_info.append(formatted('Color primaries', track['color_primaries']))
            media_info.append(formatted('Matrix coefficients', track['matrix_coefficients']))
            media_info.append('')
        elif track_type == 'Audio':
            media_info.append(formatted('ID', track['track_id']))
            media_info.append(formatted('Format', track['format']))
            media_info.append(formatted('Format/Info', track['format_info']))
            media_info.append(formatted('Codec ID', track['codec_id']))
            media_info.append(formatted('Duration', track['other_duration'][0]))
            media_info.append(formatted('Bit rate mode', track['other_bit_rate_mode'][0]))
            media_info.append(formatted('Bit rate', track['other_bit_rate'][0]))
            media_info.append(formatted('Channel(s)', track['other_channel_s'][0]))
            media_info.append(formatted('Channel positions', track['channel_positions']))
            media_info.append(formatted('Sampling rate', track['other_sampling_rate'][0]))
            media_info.append(formatted('Frame rate', track['other_frame_rate'][0]))
            media_info.append(formatted('Bit depth', track['other_bit_depth'][0]))
            media_info.append(formatted('Compression mode', track['other_compression_mode'][0]))
            media_info.append(formatted('Stream size', track['other_stream_size'][0]))
            media_info.append(formatted('Language', track['other_language'][0]))
            media_info.append(formatted('Service kind', track['other_service_kind'][0]))
            media_info.append(formatted('Default', track['other_default'][0]))
            media_info.append(formatted('Forced', track['other_forced'][0]))
            media_info.append('')
        elif track_type == 'Text':
            media_info.append(formatted('ID', track['track_id']))
            media_info.append(formatted('Format', track['format']))
            media_info.append(formatted('Codec ID', track['codec_id']))
            media_info.append(formatted('Codec ID/Info', track['codec_id_info']))
            media_info.append(formatted('Duration', track['other_duration'][0]))
            media_info.append(formatted('Bit rate', track['other_bit_rate'][0]))
            media_info.append(formatted('Count of elements', track['count_of_elements']))
            media_info.append(formatted('Stream size', track['other_stream_size'][0]))
            media_info.append(formatted('Language', track['other_language'][0]))
            media_info.append(formatted('Default', track['other_default'][0]))
            media_info.append(formatted('Forced', track['other_forced'][0]))
            media_info.append('')
        elif track_type == 'Menu':
            for k, v in track.items():
                if k[:1].isdigit():
                    media_info.append(formatted((k[:8] + '.' + k[8:]).replace('_', ':'), v))
            media_info.append('')

        return '\n'.join(media_info)

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

You mean, you'd like the same output as plain mediainfo -f <file>?

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

exactly!

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

In order to do that, you'd just have to call the library without the XML/OLDXML option, that just means removing

lib.MediaInfo_Option(None, "Inform", xml_option)

My problem is that the whole MediaInfo object is based on the XML output. Why do you want a specific format that is exactly the same as mediainfo's in your programme?

From a developer's point of view, I don't really understand when this would be useful.

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

Because when another program is packaged, (the one im writing) it is inefficient and adds another install (and requires calling a shell of some sort) when the dll can be added directly to the current installation. the mediainfo output is just a part of a much longer chunk of text and needed as it is formatted in the full program.

To remove the xml option i am going to have to pull the library and physically remove the line? or can i disable the option at runtime?

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

And you must exactly match mediainfo's output? It will be parsed by a script afterwards?
Perhaps you could simplify your code by removing all attributes starting with other_, converting words to title case and replacing underscores with spaces.
You would basically be doing the opposite of this code:

def __init__(self, xml_dom_fragment):
self.xml_dom_fragment = xml_dom_fragment
self.track_type = xml_dom_fragment.attrib['type']
for el in self.xml_dom_fragment:
node_name = el.tag.lower().strip().strip('_')
if node_name == 'id':
node_name = 'track_id'
node_value = el.text
other_node_name = "other_%s" % node_name
if getattr(self, node_name) is None:
setattr(self, node_name, node_value)
else:
if getattr(self, other_node_name) is None:
setattr(self, other_node_name, [node_value, ])
else:
getattr(self, other_node_name).append(node_value)
for o in [d for d in self.__dict__.keys() if d.startswith('other_')]:
try:
primary = o.replace('other_', '')
setattr(self, primary, int(getattr(self, primary)))
except:
for v in getattr(self, o):
try:
current = getattr(self, primary)
setattr(self, primary, int(v))
getattr(self, o).append(current)
break
except:
pass

If you need the exact same output, you need to remove the lib.MediaInfo_Option(None, "Inform", xml_option) line from the code and the return value of this call will be the text:

xml = lib.MediaInfo_Inform(handle, 0)

from pymediainfo.

PyR8zdl avatar PyR8zdl commented on May 23, 2024

Yeah I was needing this too. I like pymediainfo because it allows to get specific info but I also need to get the full mediainfo text for other functions of my script.

Was hoping to move from calling shell command to just this but seems I may need to use both.

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

from pymediainfo.

PyR8zdl avatar PyR8zdl commented on May 23, 2024

@dirtycajunrice Yes please do, That would save me a lot of time!

@sbraz It would be preferred if that was builtin to the library. I'm sure others will surely run into this.

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

Can you guys try the text branch? https://github.com/sbraz/pymediainfo/tree/text

I'm still not sure what I cant to call the new option, any suggestions?

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

Looks like the library isnt usable even without the new option being called. Im looking into it right now but example:
master:

(venv) C:\Users\nick\PycharmProjects\ReleaseMaster>python
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymediainfo import MediaInfo
>>> media_info = MediaInfo.parse("Y:\Finished Encodes\Shaolin.Kung.Fu.Master.1980\Shaolin.Kung.Fu.Master.1980.1080p.Remux.H.264-MuDBuG.mkv", library_file="lib\MediaInfo.dll")
>>>

text

(textvenv) C:\Users\nick\PycharmProjects\ReleaseMaster>python
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:05:16) [MSC v.1915 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymediainfo import MediaInfo
>>> media_info = MediaInfo.parse("Y:\Finished Encodes\Shaolin.Kung.Fu.Master.1980\Shaolin.Kung.Fu.Master.1980.1080p.Remux.H.264-MuDBuG.mkv", library_file="lib\MediaInfo.dll")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\nick\PycharmProjects\ReleaseMaster\textvenv\lib\site-packages\pymediainfo\__init__.py", line 267, in parse
    " with libmediainfo".format(filename))
RuntimeError: An eror occured while opening Y:\Finished Encodes\Shaolin.Kung.Fu.Master.1980\Shaolin.Kung.Fu.Master.1980.1080p.Remux.H.264-MuDBuG.mkv with libmediainfo
>>> MediaInfo.can_parse(library_file="lib\MediaInfo.dll")
True

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

@sbraz well apparently pip installing in a venv through git+giturl puked. I cloned and imported locally and it worked. That being said it throws up every single key... duplicatively:
without param:

>>> media_info = MediaInfo.parse("Y:\Finished Encodes\Shaolin.Kung.Fu.Master.1980\Shaolin.Kung.Fu.Master.1980.1080p.Remux.H.264-MuDBuG.mkv", library_file="..\..\PycharmProjects\ReleaseMaster\lib\MediaInfo.dll")
>>> print(media_info)
<pymediainfo.MediaInfo object at 0x0342CE30>

with param:

>>> media_info = MediaInfo.parse("Y:\Finished Encodes\Shaolin.Kung.Fu.Master.1980\Shaolin.Kung.Fu.Master.1980.1080p.Remux.H.264-MuDBuG.mkv", library_file="..\..\PycharmProjects\ReleaseMaster\lib\MediaInfo.dll", return_text=True)
>>> print(media_info)
General
Count                                    : 331
Count of stream of this kind             : 1
Kind of stream                           : General
Kind of stream                           : General
Stream identifier                        : 0
Unique ID                                : 475681201753811992851163629364361703
Unique ID                                : 475681201753811992851163629364361703 (0x5B9CE4DAC6ADB53A4BB14B8F5EB9E7)
Count of video streams                   : 1
Count of audio streams                   : 2
Count of menu streams                    : 1
Video_Format_List                        : AVC
Video_Format_WithHint_List               : AVC
Codecs Video                             : AVC
Video_Language_List                      : English
Audio_Format_List                        : PCM / PCM
Audio_Format_WithHint_List               : PCM / PCM
Audio codecs                             : PCM / PCM
Audio_Language_List                      : English / German
Complete name                            : Y:\Finished Encodes\Shaolin.Kung.Fu.Master.1980\Shaolin.Kung.Fu.Master.1980.1080p.Remux.H.264-MuDBuG.mkv
Folder name                              : Y:\Finished Encodes\Shaolin.Kung.Fu.Master.1980
File name                                : Shaolin.Kung.Fu.Master.1980.1080p.Remux.H.264-MuDBuG.mkv
File name                                : Shaolin.Kung.Fu.Master.1980.1080p.Remux.H.264-MuDBuG
File extension                           : mkv
Format                                   : Matroska
Format                                   : Matroska
Format/Url                               : https://matroska.org/downloads/windows.html
Format/Extensions usually used           : mkv mk3d mka mks
Commercial name                          : Matroska
Format version                           : Version 4
File size                                : 19188806360
File size                                : 17.9 GiB
File size                                : 18 GiB
File size                                : 18 GiB
File size                                : 17.9 GiB
File size                                : 17.87 GiB
Duration                                 : 5469798
Duration                                 : 1 h 31 min
Duration                                 : 1 h 31 min 9 s 798 ms
Duration                                 : 1 h 31 min
Duration                                 : 01:31:09.798
Duration                                 : 01:31:11;04
Duration                                 : 01:31:09.798 (01:31:11;04)
Overall bit rate mode                    : VBR
Overall bit rate mode                    : Variable
Overall bit rate                         : 28065104
Overall bit rate                         : 28.1 Mb/s
Frame rate                               : 23.976
Frame rate                               : 23.976 FPS
Frame count                              : 131144
Stream size                              : 1882413
Stream size                              : 1.80 MiB (0%)
Stream size                              : 2 MiB
Stream size                              : 1.8 MiB
Stream size                              : 1.80 MiB
Stream size                              : 1.795 MiB
Stream size                              : 1.80 MiB (0%)
Proportion of this stream                : 0.00010
IsStreamable                             : Yes
Title                                    : Shaolin Kung Fu Master [1980] 1080p Remux - MuDBuG
Movie name                               : Shaolin Kung Fu Master [1980] 1080p Remux - MuDBuG
Encoded date                             : UTC 2019-03-30 22:43:50
File creation date                       : UTC 2019-03-30 22:45:55.620
File creation date (local)               : 2019-03-30 17:45:55.620
File last modification date              : UTC 2019-03-30 22:45:55.620
File last modification date (local)      : 2019-03-30 17:45:55.620
Writing application                      : mkvmerge v32.0.0 ('Astral Progressions') 64-bit
Writing application                      : mkvmerge v32.0.0 ('Astral Progressions') 64-bit
Writing library                          : libebml v1.3.7 + libmatroska v1.5.0
Writing library                          : libebml v1.3.7 + libmatroska v1.5.0

Video
Count                                    : 374
Count of stream of this kind             : 1
Kind of stream                           : Video
Kind of stream                           : Video
Stream identifier                        : 0
StreamOrder                              : 0
ID                                       : 1
ID                                       : 1
Unique ID                                : 1
Format                                   : AVC
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format/Url                               : http://developers.videolan.org/x264.html
Commercial name                          : AVC
Format profile                           : High@L4.1
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, CABAC                   : Yes
Format settings, ReFrames                : 4
Format settings, ReFrames                : 4 frames
Format settings, GOP                     : M=3, N=18
Internet media type                      : video/H264
Codec ID                                 : V_MPEG4/ISO/AVC
Codec ID/Url                             : http://ffdshow-tryout.sourceforge.net/
Duration                                 : 5469798.000000
Duration                                 : 1 h 31 min
Duration                                 : 1 h 31 min 9 s 798 ms
Duration                                 : 1 h 31 min
Duration                                 : 01:31:09.798
Duration                                 : 01:31:11;04
Duration                                 : 01:31:09.798 (01:31:11;04)
Bit rate mode                            : VBR
Bit rate mode                            : Variable
Bit rate                                 : 24992295
Bit rate                                 : 25.0 Mb/s
Maximum bit rate                         : 29999616
Maximum bit rate                         : 30.0 Mb/s
Width                                    : 1920
Width                                    : 1 920 pixels
Height                                   : 1080
Height                                   : 1 080 pixels
Stored_Height                            : 1088
Sampled_Width                            : 1920
Sampled_Height                           : 1080
Pixel aspect ratio                       : 1.000
Display aspect ratio                     : 1.778
Display aspect ratio                     : 16:9
Frame rate mode                          : CFR
Frame rate mode                          : Constant
Frame rate                               : 23.976
Frame rate                               : 23.976 (24000/1001) FPS
FrameRate_Num                            : 24000
FrameRate_Den                            : 1001
Frame count                              : 131144
Standard                                 : NTSC
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Chroma subsampling                       : 4:2:0
Bit depth                                : 8
Bit depth                                : 8 bits
Scan type                                : Progressive
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.503
Delay                                    : 0
Delay                                    : 00:00:00.000
Delay, origin                            : Container
Delay, origin                            : Container
Stream size                              : 17087851307
Stream size                              : 15.9 GiB (89%)
Stream size                              : 16 GiB
Stream size                              : 16 GiB
Stream size                              : 15.9 GiB
Stream size                              : 15.91 GiB
Stream size                              : 15.9 GiB (89%)
Proportion of this stream                : 0.89051
Language                                 : en
Language                                 : English
Language                                 : English
Language                                 : en
Language                                 : eng
Language                                 : en
Default                                  : No
Default                                  : No
Forced                                   : No
Forced                                   : No
Buffer size                              : 30000000 / 30000000
colour_description_present               : Yes
colour_description_present_Source        : Stream
Color range                              : Limited
colour_range_Source                      : Stream
Color primaries                          : BT.709
colour_primaries_Source                  : Stream
Transfer characteristics                 : BT.709
transfer_characteristics_Source          : Stream
Matrix coefficients                      : BT.709
matrix_coefficients_Source               : Stream

Audio #1
Count                                    : 277
Count of stream of this kind             : 2
Kind of stream                           : Audio
Kind of stream                           : Audio
Stream identifier                        : 0
Stream identifier                        : 1
StreamOrder                              : 1
ID                                       : 2
ID                                       : 2
Unique ID                                : 2
Format                                   : PCM
Format                                   : PCM
Commercial name                          : PCM
Format settings                          : Little / Signed
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : A_PCM/INT/LIT
Duration                                 : 5466335.000000
Duration                                 : 1 h 31 min
Duration                                 : 1 h 31 min 6 s 335 ms
Duration                                 : 1 h 31 min
Duration                                 : 01:31:06.335
Duration                                 : 01:31:06:11
Duration                                 : 01:31:06.335 (01:31:06:11)
Bit rate mode                            : CBR
Bit rate mode                            : Constant
Bit rate                                 : 1536000
Bit rate                                 : 1 536 kb/s
Channel(s)                               : 2
Channel(s)                               : 2 channels
Samples per frame                        : 1600
Sampling rate                            : 48000
Sampling rate                            : 48.0 kHz
Samples count                            : 262384080
Frame rate                               : 30.000
Frame rate                               : 30.000 FPS (1600 SPF)
Frame count                              : 163991
Bit depth                                : 16
Bit depth                                : 16 bits
Delay                                    : 0
Delay                                    : 00:00:00.000
Delay, origin                            : Container
Delay, origin                            : Container
Delay relative to video                  : 0
Delay relative to video                  : 00:00:00.000
Stream size                              : 1049536320
Stream size                              : 1 001 MiB (5%)
Stream size                              : 1 001 MiB
Stream size                              : 1 001 MiB
Stream size                              : 1 001 MiB
Stream size                              : 1 000.9 MiB
Stream size                              : 1 001 MiB (5%)
Proportion of this stream                : 0.05470
Language                                 : en
Language                                 : English
Language                                 : English
Language                                 : en
Language                                 : eng
Language                                 : en
Default                                  : Yes
Default                                  : Yes
Forced                                   : No
Forced                                   : No

Audio #2
Count                                    : 277
Count of stream of this kind             : 2
Kind of stream                           : Audio
Kind of stream                           : Audio
Stream identifier                        : 1
Stream identifier                        : 2
StreamOrder                              : 2
ID                                       : 3
ID                                       : 3
Unique ID                                : 3
Format                                   : PCM
Format                                   : PCM
Commercial name                          : PCM
Format settings                          : Little / Signed
Format settings, Endianness              : Little
Format settings, Sign                    : Signed
Codec ID                                 : A_PCM/INT/LIT
Duration                                 : 5466335.000000
Duration                                 : 1 h 31 min
Duration                                 : 1 h 31 min 6 s 335 ms
Duration                                 : 1 h 31 min
Duration                                 : 01:31:06.335
Duration                                 : 01:31:06:11
Duration                                 : 01:31:06.335 (01:31:06:11)
Bit rate mode                            : CBR
Bit rate mode                            : Constant
Bit rate                                 : 1536000
Bit rate                                 : 1 536 kb/s
Channel(s)                               : 2
Channel(s)                               : 2 channels
Samples per frame                        : 1600
Sampling rate                            : 48000
Sampling rate                            : 48.0 kHz
Samples count                            : 262384080
Frame rate                               : 30.000
Frame rate                               : 30.000 FPS (1600 SPF)
Frame count                              : 163991
Bit depth                                : 16
Bit depth                                : 16 bits
Delay                                    : 0
Delay                                    : 00:00:00.000
Delay, origin                            : Container
Delay, origin                            : Container
Delay relative to video                  : 0
Delay relative to video                  : 00:00:00.000
Stream size                              : 1049536320
Stream size                              : 1 001 MiB (5%)
Stream size                              : 1 001 MiB
Stream size                              : 1 001 MiB
Stream size                              : 1 001 MiB
Stream size                              : 1 000.9 MiB
Stream size                              : 1 001 MiB (5%)
Proportion of this stream                : 0.05470
Language                                 : de
Language                                 : German
Language                                 : German
Language                                 : de
Language                                 : deu
Language                                 : de
Default                                  : No
Default                                  : No
Forced                                   : No
Forced                                   : No

Menu
Count                                    : 100
Count of stream of this kind             : 1
Kind of stream                           : Menu
Kind of stream                           : Menu
Stream identifier                        : 0
Chapters_Pos_Begin                       : 94
Chapters_Pos_End                         : 100
00:00:00.000                             : en:Chapter 01
00:07:15.351                             : en:Chapter 02
00:20:04.119                             : en:Chapter 03
00:38:47.491                             : en:Chapter 04
00:59:04.916                             : en:Chapter 05
01:20:57.936                             : en:Chapter 06

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

Looking above I see that you referenced -f and just assumed without looking that it was an arg to specify a file. What I (and i assume @PyR8zdl) are looking for is the output of mediainfo filename (sans -f)
(the equivalent of detail - 0)

The above would have been a simple loop with "if value.. print, if value is in a list, print list[0], key to TitleCase remove snake_case"

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

As its text, and the keys are duplicative... there would be just as much code to sanitize that as there would be to create it in the first place (like above). As for the parse function options, 5 (6 with the addition of full=False) is very very efficient in contrast to many libraries with 15+ options haha. In a perfect world it would have 0, 5, 9, and 10 for detail levels but as mediainfo as a command line option only has 0 and 10 (0 being basic/no -f and 10 being full/-f), full=False would give feature parity

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

Amazing! Thank you @sbraz

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

@PyR8zdl @dirtycajunrice what do you think of the return_text name? I'm not sure this is the best name to use and yet I don't have a better idea.

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

if there only will ever be text / xml, and text wil be “opt in”, you could make it text=True. other than that i dont of a better option than “ouptut=text” with xml default and .lower()

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

Well XML is not something end users should have to worry about since it's then converted to dicts and other objects. I guess text=True would be better then.

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

true. its just internal for the library. i will support whatever you decide :D

from pymediainfo.

sbraz avatar sbraz commented on May 23, 2024

Text option added in 4885aec and full option in 9790ad7.
I will release a new version soon.

from pymediainfo.

dirtycajunrice avatar dirtycajunrice commented on May 23, 2024

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.