sangwonl/python-mpegdash

Wrong type of SubRepresentation.content_component

nirb999 opened this issue · 3 comments

In file mpegdash/nodes.py:

self.content_component = parse_attr_value(xmlnode, 'contentComponent', [str])

shouldn't it be:
self.content_component = parse_attr_value(xmlnode, 'contentComponent', str)
or
self.content_component = parse_attr_value(xmlnode, 'contentComponent', int)
?

try this code:

import mpegdash.parser

mpd = '''
<MPD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mpeg:dash:schema:mpd:2011" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 http://standards.iso.org/ittf/PubliclyAvailableStandards/MPEG-DASH_schema_files/DASH-MPD.xsd" type="dynamic" minimumUpdatePeriod="PT30S" availabilityStartTime="2014-02-05T22:29:56" minBufferTime="PT12S" timeShiftBufferDepth="PT1M0S" profiles="urn:mpeg:dash:profile:isoff-live:2011">
  <BaseURL>http://test-i.akamaihd.net/dash/live/500002/linearprogram1</BaseURL>
  <BaseURL>http://test-i.akamaihd.net/dash/live/500002-b/linearprogram</BaseURL>
  <Period start="PT0S" duration="PT1M0.6S" id="1">
    <AdaptationSet mimeType="video/mp4" codecs="avc1.42CE,mp4a.40.5" frameRate="15000/1001" segmentAlignment="true" subsegmentAlignment="true" startWithSAP="1" subsegmentstartWithSAP="1" bitstreamSwitching="true">
      <ContentComponent contentType="video" id="1" />
      <SegmentTemplate timescale="90000" duration="540000" startNumber="74247" />
      <Representation id="1" width="640" height="360" bandwidth="600000">
        <SubRepresentation contentComponent="1" bandwidth="600000" codecs="avc1.42C01E" />
        <SegmentTemplate duration="540000" startNumber="74247" media="dash_video600-$Number$.mp4" initialization="dash_video600-.init" />
      </Representation>
      <Representation id="2" width="320" height="180" bandwidth="200000">
        <SubRepresentation contentComponent="1" bandwidth="200000" codecs="avc1.42C01E" />
        <SegmentTemplate duration="540000" startNumber="74248" media="dash_video200-$Number$.mp4" initialization="dash_video200-.init" />
      </Representation>
    </AdaptationSet>
  </Period>
</MPD>
'''

parsed_mpd = mpegdash.parser.MPEGDASHParser.parse(mpd)
new_mpd = mpegdash.parser.MPEGDASHParser.toprettyxml(parsed_mpd)
print(new_mpd)

The output contains this: contentComponent="[<class 'str'>]" :

<?xml version="1.0" ?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" type="dynamic" profiles="urn:mpeg:dash:profile:isoff-live:2011" availabilityStartTime="2014-02-05T22:29:56" minimumUpdatePeriod="PT30S" minBufferTime="PT12S" timeShiftBufferDepth="PT1M0S">
    <BaseURL>http://test-i.akamaihd.net/dash/live/500002/linearprogram1</BaseURL>
    <BaseURL>http://test-i.akamaihd.net/dash/live/500002-b/linearprogram</BaseURL>
    <Period id="1" start="PT0S" duration="PT1M0.6S">
        <AdaptationSet frameRate="15000/1001" mimeType="video/mp4" codecs="avc1.42CE,mp4a.40.5" startWithSAP="1" segmentAlignment="true" subsegmentAlignment="true" bitstreamSwitching="true">
            <ContentComponent id="1" contentType="video"/>
            <SegmentTemplate timescale="90000" duration="540000" startNumber="74247"/>
            <Representation width="640" height="360" id="1" bandwidth="600000">
                <SegmentTemplate duration="540000" startNumber="74247" media="dash_video600-$Number$.mp4" initialization="dash_video600-.init"/>
                <SubRepresentation codecs="avc1.42C01E" bandwidth="600000" contentComponent="[&lt;class 'str'&gt;]"/>
            </Representation>
            <Representation width="320" height="180" id="2" bandwidth="200000">
                <SegmentTemplate duration="540000" startNumber="74248" media="dash_video200-$Number$.mp4" initialization="dash_video200-.init"/>
                <SubRepresentation codecs="avc1.42C01E" bandwidth="200000" contentComponent="[&lt;class 'str'&gt;]"/>
            </Representation>
        </AdaptationSet>
    </Period>
</MPD>

manifest example taken from here:
https://learn.akamai.com/en-us/webhelp/media-services-live/media-services-live-hls-hds-and-dash-ingest-user-guide-v3.2/GUID-A32F2823-ED4D-470B-9BC3-C4C455FE2F47.html

Yes, it should probably be str. dependencyLevel should probably be str too. Either these, or they should be parsed and written "properly", ie as whitespace-seperated lists.

As it is, is is definitely wrong 😄

Hi guys, I believe #48 should fix the bug. Could you try it and share if it works?

Thanks.

Closing this issue for now since it looks to work with the patch, but if it's still happening please file a new issue. Thanks.