Ahoj.
Mám takovýto xml soubor (viz.přiložený soubor)  - export z ffprobe. 

Pro ty hodnoty, které jsou u <stream používám toto:





from xml.dom import minidom

xmldoc = minidom.parse('RainS02E06.mkv.xml')


streamlist = xmldoc.getElementsByTagName('stream')



for s in streamlist:

    print(s.attributes['index'].value)

    print(s.attributes['codec_name'].value)

    try:

        print(s.attributes['sample_rate'].value)

    except:

        print('none')






ale nevím jakým způsobem se dostat k těm "hlubším" hodnotám - např.

<tag key="DURATION-eng" - jaká je např.hodnota value u stream index="1"





Mohli byste mi, prosím, poradit?




Děkuji Ctibor











<?xml version="1.0" encoding="UTF-8"?>
<ffprobe>
    <streams>
        <stream index="0" codec_name="h264" codec_long_name="H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10" profile="Main" codec_type="video" codec_time_base="1/50" codec_tag_string="[0][0][0][0]" codec_tag="0x0000" width="1920" height="1080" coded_width="1920" coded_height="1088" has_b_frames="1" sample_aspect_ratio="1:1" display_aspect_ratio="16:9" pix_fmt="yuv420p" level="40" chroma_location="left" field_order="progressive" refs="1" is_avc="true" nal_length_size="4" r_frame_rate="25/1" avg_frame_rate="25/1" time_base="1/1000" start_pts="0" start_time="0.000000" bits_per_raw_sample="8">
            <disposition default="1" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0" timed_thumbnails="0"/>
            <tag key="BPS-eng" value="4185187"/>
            <tag key="DURATION-eng" value="00:42:24.360000000"/>
            <tag key="NUMBER_OF_FRAMES-eng" value="63609"/>
            <tag key="NUMBER_OF_BYTES-eng" value="1331077830"/>
            <tag key="_STATISTICS_WRITING_APP-eng" value="mkvmerge v21.0.0 (&apos;Tardigrades Will Inherit The Earth&apos;) 64-bit"/>
            <tag key="_STATISTICS_WRITING_DATE_UTC-eng" value="2019-05-17 07:12:54"/>
            <tag key="_STATISTICS_TAGS-eng" value="BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES"/>
            <tag key="DURATION" value="00:42:24.383000000"/>
        </stream>
        <stream index="1" codec_name="mp3" codec_long_name="MP3 (MPEG audio layer 3)" codec_type="audio" codec_time_base="1/48000" codec_tag_string="[0][0][0][0]" codec_tag="0x0000" sample_fmt="fltp" sample_rate="48000" channels="2" channel_layout="stereo" bits_per_sample="0" r_frame_rate="0/0" avg_frame_rate="0/0" time_base="1/1000" start_pts="0" start_time="0.000000" bit_rate="128000">
            <disposition default="1" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0" timed_thumbnails="0"/>
            <tag key="language" value="dan"/>
            <tag key="title" value="Danish"/>
            <tag key="BPS-eng" value="640000"/>
            <tag key="DURATION-eng" value="00:42:24.416000000"/>
            <tag key="NUMBER_OF_FRAMES-eng" value="79513"/>
            <tag key="NUMBER_OF_BYTES-eng" value="203553280"/>
            <tag key="_STATISTICS_WRITING_APP-eng" value="mkvmerge v21.0.0 (&apos;Tardigrades Will Inherit The Earth&apos;) 64-bit"/>
            <tag key="_STATISTICS_WRITING_DATE_UTC-eng" value="2019-05-17 07:12:54"/>
            <tag key="_STATISTICS_TAGS-eng" value="BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES"/>
            <tag key="ENCODER" value="Lavc58.32.100 libmp3lame"/>
            <tag key="DURATION" value="00:42:24.439000000"/>
        </stream>
        <stream index="2" codec_name="subrip" codec_long_name="SubRip subtitle" codec_type="subtitle" codec_time_base="0/1" codec_tag_string="[0][0][0][0]" codec_tag="0x0000" r_frame_rate="0/0" avg_frame_rate="0/0" time_base="1/1000" start_pts="0" start_time="0.000000" duration_ts="2544439" duration="2544.439000">
            <disposition default="0" dub="0" original="0" comment="0" lyrics="0" karaoke="0" forced="0" hearing_impaired="0" visual_impaired="0" clean_effects="0" attached_pic="0" timed_thumbnails="0"/>
            <tag key="language" value="cze"/>
            <tag key="BPS-eng" value="38"/>
            <tag key="DURATION-eng" value="00:39:36.480000000"/>
            <tag key="NUMBER_OF_FRAMES-eng" value="449"/>
            <tag key="NUMBER_OF_BYTES-eng" value="11376"/>
            <tag key="_STATISTICS_WRITING_APP-eng" value="mkvmerge v21.0.0 (&apos;Tardigrades Will Inherit The Earth&apos;) 64-bit"/>
            <tag key="_STATISTICS_WRITING_DATE_UTC-eng" value="2019-05-17 07:12:54"/>
            <tag key="_STATISTICS_TAGS-eng" value="BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES"/>
            <tag key="DURATION" value="00:39:43.548000000"/>
        </stream>
    </streams>

    <format filename="RainS02E06.mkv" nb_streams="3" nb_programs="0" format_name="matroska,webm" format_long_name="Matroska / WebM" start_time="0.000000" duration="2544.439000" size="1373124712" bit_rate="4317257" probe_score="100">
        <tag key="ENCODER" value="Lavf58.18.104"/>
    </format>
</ffprobe>
_______________________________________________
Python mailing list
python@py.cz
http://www.py.cz/mailman/listinfo/python

Visit: http://www.py.cz

Odpovedet emailem