I have an example of MPD file generated by Wowza.
I'd like to find out what are URLs of media segments.
The DASH specification is not easy to decipher.
The example is like this
-<Period start="PT0.0S" id="0">
-<AdaptationSet id="0" subsegmentStartsWithSAP="1" subsegmentAlignment="true" startWithSAP="1" segmentAlignment="true" frameRate="30" par="16:9" height="720" width="1280" mimeType="video/mp4">
-<SegmentTemplate initialization="chunk_ctvideo_cfm4s_rid$RepresentationID$_cinit_w998693597_mpd.m4s" media="chunk_ctvideo_cfm4s_rid$RepresentationID$_cs$Time$_w998693597_mpd.m4s" timescale="90000">
-<SegmentTimeline>
<S d="720000" t="35576570970"/>
<S d="720000"/>
<S d="1440000"/>
<S d="720000"/>
<S d="720000"/>
</SegmentTimeline>
</SegmentTemplate>
<Representation id="p0a0r0" bandwidth="296000" sar="1:1" codecs="avc1.4d401f"/>
</AdaptationSet>
The format is in SegmentTemplate tag:
initialization="chunk_ctvideo_cfm4s_rid$RepresentationID$_cinit_w998693597_mpd.m4s" media="chunk_ctvideo_cfm4s_rid$RepresentationID$_cs$Time$_w998693597_mpd.m4s" timescale="90000">
initialization="chunk_ctvideo_cfm4s_rid$RepresentationID$_cinit_w998693597_mpd.m4s"
This tells you the template URL of initial segment.
Replace $RepresentationID$ with "Representation id" (p0a0r0 in your example).
media="chunk_ctvideo_cfm4s_rid$RepresentationID$_cs$Time$_w998693597_mpd.m4s"
This tells you the template URL of media segments. Replace $RepresentationID$ with "Representation id" as above, and replace $Time$ with a value computed from "SegmentTimeline" tag.
For example,
say the url for mpd is http:///XXX/manifest.mpd
the url for initial segment is http:///XXX/chunk_ctvideo_cfm4s_ridp0a0r0_cinit_w998693597_mpd.m4s
and the url for a media segment can be
http:///XXX/chunk_ctvideo_cfm4s_ridp0a0r0_cs35576570970_w998693597_mpd.m4s
If you want to get different media segments in a representation, you can use different $Time$ value in url.
Hope this helps.
Related
I try to manipulate an diagrams.net (formerly draw.io) not compressed XML exported drawing.
Cables can be hooked up to elements and I want to get a cables-list.
I do a search for all cables by testing if the element has source and target attributes. Then I compare the id's of both with the full list of elements to find the connected label in value.
That works great until someone tries to add an "addon-tag". After that (even if it's deleted), the element gets wrapped in a <object> that has the id attribute but the source and target attribute stay in a child node called like this:
before:
<mxCell id="ferXMembXyNwfAPwV5vA-22" value="" style="..endless list" edge="1" parent="1" source="ferXMembXyNwfAPwV5vA-8" target="ferXMembXyNwfAPwV5vA-18">
<mxGeometry relative="1" as="geometry">
<mxPoint x="540" y="520" as="sourcePoint" />
<mxPoint x="700" y="520" as="targetPoint" />
</mxGeometry>
</mxCell>
after:
<object label="" id="ferXMembXyNwfAPwV5vA-53">
<mxCell style="..endless long list" edge="1" parent="1" source="ferXMembXyNwfAPwV5vA-42" target="ferXMembXyNwfAPwV5vA-51">
<mxGeometry relative="1" as="geometry">
<mxPoint x="660" y="340" as="sourcePoint" />
<mxPoint x="770" y="360" as="targetPoint" />
</mxGeometry>
</mxCell>
</object>
this findall works for normal mxCell formated to find id, source and target elements:
list_of_mxCell_elements = root.findall(root_node,".//*[#source][#target]")
and this for objects elements id's:
list_of_objects_elements = root.findall(root_node,".//*[#source][#target]/..")
But how can I access the mxCell element from the list_of_objects_elements, so I can get hold of source and target id's?
I found a solution by my own.
After findall 'elements' i iterate over the list of elements and just do another findall on each cable element i got.
It looks somewhat like this:
list_of_objects_elements = root.findall(root_node,'.//*[#source][#target]/..')
for cable in list_of_objects_elements:
for mxCell in cable.findall('./*[#source][#target]'):
Note the slighly different findall path:
This makes an search for source & target in <mxCells> while passing back the next higher element <object> from root.
.//*[#source][#target]/..
./*[#source][#target]
While the lower searches for source & target in only one element deeper than <object>
To me those paths are still a Mindblow.
<Period programDateTime='2021-03-17T07:15:26.239Z' duration='PT1M04.078S'>
<AdaptationSet contentType='video' mimeType='video/mp4' par='16:9' id='7'>
<SegmentList timescale='90000' presentationTimeOffset='4327131510'>
<SegmentTimeline>
<!-- Doesn't work -->
<S t='4327131510' d='2903310' r='1' />
<!-- Uncomment below and remove the above and manifest will work -->
<!-- <S t='4327131510' d='2903310'/>-->
<!-- <S t='4330034820' d='2903310'/>-->
</SegmentTimeline>
</SegmentList>
<Representation id='1280x720' codecs='avc1.4d0029' width='1280' height='720' bandwidth='100000'>
<BaseURL>http://localhost:8000/downloaded/</BaseURL>
<SegmentList>
<Initialization sourceURL='1.m4v' />
<SegmentURL media='1.m4v' />
<SegmentURL media='2.m4v' />
</SegmentList>
</Representation>
</AdaptationSet>
</Period>
Dash player starts playing the manifest however, it skips the 2.m4v and reduces the size of video to just first segment. However, if I remove the repeat count field and specify each segment explicitly in segmentTimeline then it works fine.
This manifest also works fine in Shaka player.
Your manifest doesn't look right. I don't think the first segment list with the time line should be there. I would try:
<Period programDateTime='2021-03-17T07:15:26.239Z' duration='PT1M04.078S'>
<AdaptationSet contentType='video' mimeType='video/mp4' par='16:9' id='7'>
<Representation id='1280x720' codecs='avc1.4d0029' width='1280' height='720' bandwidth='100000'>
<BaseURL>http://localhost:8000/downloaded/</BaseURL>
<SegmentList timescale='90000' duration='2903310'>
<Initialization sourceURL='1.m4v' />
<SegmentURL media='1.m4v' />
<SegmentURL media='2.m4v' />
</SegmentList>
</Representation>
</AdaptationSet>
</Period>
I'm using WP All Import to import new products from an XML, or update them. The import works perfect, but I noticed that some attributes are double. They have been created again, after first import.
Maybe for new items. I checked XML file and it is normal.
I want to import toners and I'm using an attribute for color (Χρώμα in greek) and now i have 2 different attributes named Χρώμα with the same colors. Looking for CYAN color, I found 5 products in the first attribute and 11 products in the second one.
Any idea what I'm doing wrong?
Here is the xml from one product:
<product>
<id>1077</id>
<sku>TON-CLP320BK</sku>
<name>
Συμβατό Toner TON-CLP320BK για Samsung, CLT-K4072S, Black, 1.5K
</name>
<barcode>5202705407213</barcode>
<manufacturer>PREMIUM</manufacturer>
<descr>
<p>Συμβατό Toner TON-CLP320BK για Samsung, CLT-K4072S, Black, 1.5K</p><p></p><p>Συμβατά μοντέλα : </p><p>CLP325<br/>CLP320<br/>CLP320N<br/>CLP325W<br/>CLX3185FN<br/>CLX3185FN<br/>CLX318<br/>CLX318FN<br/>CLX3185FW<br/>CLX3185W</p>
</descr>
<availability>1</availability>
<dim1>40.0</dim1>
<dim2>9.5</dim2>
<dim3>18.5</dim3>
<weight>0.791</weight>
<tax>0.000</tax>
<stock_indicator>20</stock_indicator>
<minimum_quantity_to_order>1</minimum_quantity_to_order>
<RRP>15.00</RRP>
<url>
https://www.data-media.gr/product_det.asp?catid=263&subid=329&prid=1077
</url>
<thumb>
https://www.data-media.gr/photos/TON-CLP320BK.jpg
</thumb>
<image>
https://www.data-media.gr/photos/max/TON-CLP320BK.jpg
</image>
<volume>7030.000</volume>
<courier_weight>1.786</courier_weight>
<in_offer>0</in_offer>
<guarantee>12 μήνες</guarantee>
<group>
<id>4</id>
<name>Εκτυπωτές & Toner-Ink</name>
<category>
<id>263</id>
<name>Toner - Ribbon Μελάνια</name>
<subcategory>
<id>329</id>
<name>Toner</name>
</subcategory>
</category>
</group>
<filters>
<filter>
<name_id>9</name_id>
<name>Για Brand</name>
<value_id>8</value_id>
<value>SAMSUNG</value>
</filter>
<filter></filter>
<filter></filter>
<filter></filter>
</filters>
<price>10.16</price>
<price_without_offer>10.16</price_without_offer>
<retail_percent>20</retail_percent>
<retail_price>15.12</retail_price>
<vat>24</vat>
<pp>0</pp>
</product>
I created some custom svg attributes yet want to pass the svg validator test.
I saw the D3 > Namespace page, the previous How can I specify a custom XML/SVG namespace with D3.js? and thus processed as follow:
// d3.ns.prefix.geo = "http://www.example.com/boundingbox/";
// d3.ns.prefix.inkscape = "http://www.inkscape.org/namespaces/inkscape";
// SVG injection:
var width = 600;
var svg = d3.select("#hook").append("svg")
.attr("name", "Country's_name_administrative_map_\(2015\)")
.attr("id", "Country_s_name")
.attr("width", width)
.attr(':xmlns:geo','http://www.example.com/boundingbox/')
.attr(':xmlns:inkscape','http://www.inkscape.org/namespaces/inkscape')
.attr(":xmlns:cc","http://creativecommons.org/ns#");
// Tags:
svg.append(":geo:g")
.attr(':xmlns:geo','http://www.example.com/boundingbox/')
.attr(":geo:id","geo")
.attr(':geo:syntax', "WSEN bounding box in decimal degrees")
.attr(':geo:west', WEST)
.attr('geo:south', SOUTH)
.attr(':geo:east', EAST)
.attr(':geo:north', NORTH)
.attr(':geo:title', title);
Produce :
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg"
name="Country's_name_administrative_map_(2015)"
id="Country_s_name"
xmlns:geo="http://www.example.com/boundingbox/"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:cc="http://creativecommons.org/ns#"
width="600"
height="579.2009758421691"
version="1.1">
<defs xmlns="http://www.w3.org/1999/xhtml">
<style type="text/css"><![CDATA[
svg { border: 1px solid rgb(100, 100, 100); }]]>
</style>
</defs>
<geo:g xmlns:geo="http://www.example.com/boundingbox/"
geo:id="geo"
geo:syntax="WSEN bounding box in decimal degrees"
geo:west="-5.8"
south="41"
geo:east="10"
geo:north="51.5"
geo:title="Country's name" />
<defs><pattern id="hash2_4" width="6" h…
…
</svg>
I still get all the errors (larger image) :
The first type of error is related to the custom <geo:g … > element itself, visible above. The 2nd type of errors is related to custom attributes such geo:west="…" or inkscape:group="…", which I expected to be valid due to the earlier xmlns declarations.
Am I walking the wrong road ? How to make custom attribute valid via d3js ?
EDIT: a minimal jsfiddle provide a demo of the buggy output.
About d3js and namespaces. According to Selvin on D3 doesn't append xmlns:something namespace properly to svg element, it's a D3js know bug with known but not yet implemented solution. Also, current way to overcome it is via JQuery
I made some mildly successful tries.
1) Reading: To produce valid svg document which could be saved, #Selim pointed out that d3.ns.prefix is NOT suitable (see d3 doesn't append namespace attributes to svg element ).
2) Reading more: So I read Namespaces Crash Course. The key point is that
[...] namespace prefixes are used to prefix attribute names and tag [element] names [...]
From the official doc with declaration and usages, for the attributes (<script> changed into <a>) :
<svg xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href="space-rocket.html">...</a>
</svg>
and for elements:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:svg="http://www.w3.org/2000/svg">
<body>
<h1>SVG embedded inline in XHTML</h1>
<svg:svg width="300px" height="200px">
<svg:circle cx="150" cy="100" r="50" fill="#ff0000"/>
</svg:svg>
</body>
</html>
2) Porting: So I went ahead, NOT d3.ns.prefix, but with the handmade custom namespace ("geo") declaration as an attribute to the svg element via :
d3.select("svg").attr(":xmlns:geo","http://www.example.com/something/")
together with usages such
svg.append("geo").attr("id","geo")
.attr('manual', "WSEN bounding box in decimal degrees")
.attr('WEST', "-4.05")
.attr('SOUTH', "40.5")
.attr('EAST', "10.0")
.attr('NORTH', "54.5")
.attr('Title', "Imaginary map of Kinglons ruling Europe");
or
svg.append("geo").attr("id","geo")
.attr(':geo:manual', "WSEN bounding box in decimal degrees")
.attr(':geo:WEST', "-4.05")
.attr(':geo:SOUTH', "40.5")
.attr(':geo:EAST', "10.0")
.attr(':geo:NORTH', "54.5")
.attr(':geo:Title', "Imaginary map of Kinglons ruling Europe");
or
svg.append(":geo:geo").attr("id","geo")
.attr(':geo:manual', "WSEN bounding box in decimal degrees")
.attr(':geo:WEST', "-4.05")
.attr(':geo:SOUTH', "40.5")
.attr(':geo:EAST', "10.0")
.attr(':geo:NORTH', "54.5")
.attr(':geo:Title', "Imaginary map of Kinglons ruling Europe");
and about 3 other variants, but none is valid, all fails the svg validator.
I have no more ideas how to get a valid svg.
Fiddle (downloadable) , svg validator
I am looking for a way to say set a maxWidth size to 80% in FXML.
Much like in web development.
<VBox fx:id="testVB" prefWidth="600">
But this does not:
<VBox fx:id="testVB" prefWidth="80%">
I know that in Straight JavaFX2 non-fxml you can create insets? What is the best way to do this outside of code in FMXL?
Thanks!
Riley
I'm not sure you can. You need to use the GridPane layout component. In this component, you can specify rows and columns constraints, and in these constraints you can specify a width as a percentage. For example:
<GridPane>
<children>
<TitledPane text="testGridPane" GridPane.columnIndex="0" GridPane.rowIndex="0" />
</children>
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="80.0" prefWidth="100.0" />
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" percentWidth="20.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
</GridPane>
This code defines a GridPane with a first column with a width of 80%. The TitledPane is set in the first cell of the first column of this GridPane, and can (because you need to be sure that the width constraints of the TitledPane match your needs) occupy 80% of the width of the GridPane.
Please note that I removed all information not relevant to your question. By the way, Oracle's Scene Builder tool is very useful to define complex FXML layout.
It seems like many answers have already been provided and they should work. However, there is a way to set percentages:
<fx:define>
<Screen fx:factory="getPrimary" fx:id="screen" />
</fx:define>
This would help you detect the dimensions of the current screen, the application is being displayed on. Now that we have the display dimensions, we can play with it in FXML as follows:
<HBox fx:id="hroot" prefHeight="${screen.visualBounds.height}" prefWidth="${screen.visualBounds.width}"> Your FXML elements inside the root... </HBox>
Note that I use visualBounds, since this would get me the available space on the screen, since I don't want an overlap with the taskbar in Windows for example. For fullscreen applications, you would just use 'bounds'.
Now, to come to your point of using percentages, you can actually play with the value of the prefheight and prefWidth. You can put calculations inside the ${}.
Optionally:
If you want to have all your elements use relative sizes, just refer to them, using their ID and width or height property, and make your calculation.
<VBox fx:id="VBSidebar" prefWidth="${hroot.width*0.15}" prefHeight="${hroot.height}"> more elements.. </VBox>
Hope this helps!
You can simulate it - basic example that simulates 50% for two cols in an HBox. You can add dummy panes to get thirds, etc.
HBox {
VBox {
static hgrow : "ALWAYS",
Label {
text : "Privacy",
alignment : "CENTER",
styleClass : ["h2", "heading"]
}
},
VBox {
static hgrow : "ALWAYS",
Label {
text : "Messages",
alignment : "CENTER",
styleClass : ["h2", "heading"]
},
Label {text:""}
}
}