I have an XML file like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>
<fcpxml version="1.9">
<resources>
<format id="r1" name="FFVideoFormat1080p60.0" frameDuration="50/3000s" width="1920" height="1080" colorSpace="1-1-1 (Rec. 709)"/>
<asset id="r2" name="1x.mp4" start="0s" hasVideo="1" format="r1" hasAudio="1" audioSources="1" audioChannels="2" duration="1731150/3000s">
<media-rep kind="original-media" src="file:///Users/shrikant/Desktop/1x.mp4"></media-rep>
</asset>
</resources>
<library>
<event name="auto-editor output">
<project name="1x.mp4">
<sequence format="r1" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
<spine>
<asset-clip name="1x.mp4" offset="0s" ref="r2" duration="1400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="1400/3000s" ref="r2" duration="3250/3000s" start="41400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="4650/3000s" ref="r2" duration="4300/3000s" start="74700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="8950/3000s" ref="r2" duration="3850/3000s" start="105950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="12800/3000s" ref="r2" duration="8250/3000s" start="124500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="21050/3000s" ref="r2" duration="3150/3000s" start="148400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="24200/3000s" ref="r2" duration="2150/3000s" start="155850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="26350/3000s" ref="r2" duration="13700/3000s" start="158450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="40050/3000s" ref="r2" duration="6950/3000s" start="189800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="47000/3000s" ref="r2" duration="7500/3000s" start="197150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="54500/3000s" ref="r2" duration="250/3000s" start="205150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="54750/3000s" ref="r2" duration="3350/3000s" start="219150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="58100/3000s" ref="r2" duration="100/3000s" start="229600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="58200/3000s" ref="r2" duration="1500/3000s" start="230100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="59700/3000s" ref="r2" duration="12950/3000s" start="235950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="72650/3000s" ref="r2" duration="22550/3000s" start="266300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="95200/3000s" ref="r2" duration="3650/3000s" start="291050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="98850/3000s" ref="r2" duration="3550/3000s" start="295150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="102400/3000s" ref="r2" duration="4450/3000s" start="299350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="106850/3000s" ref="r2" duration="100/3000s" start="321300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="106950/3000s" ref="r2" duration="6850/3000s" start="328050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="113800/3000s" ref="r2" duration="50/3000s" start="348850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="113850/3000s" ref="r2" duration="10550/3000s" start="349650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="124400/3000s" ref="r2" duration="13600/3000s" start="377400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="138000/3000s" ref="r2" duration="6050/3000s" start="391400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="144050/3000s" ref="r2" duration="11100/3000s" start="397900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="155150/3000s" ref="r2" duration="250/3000s" start="409700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="155400/3000s" ref="r2" duration="3350/3000s" start="414450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="158750/3000s" ref="r2" duration="11700/3000s" start="423850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="170450/3000s" ref="r2" duration="4950/3000s" start="436550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="175400/3000s" ref="r2" duration="1150/3000s" start="442100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="176550/3000s" ref="r2" duration="1250/3000s" start="455950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="177800/3000s" ref="r2" duration="150/3000s" start="459500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="177950/3000s" ref="r2" duration="2350/3000s" start="464050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="180300/3000s" ref="r2" duration="100/3000s" start="467350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="180400/3000s" ref="r2" duration="250/3000s" start="483300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="180650/3000s" ref="r2" duration="13700/3000s" start="484450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="194350/3000s" ref="r2" duration="1400/3000s" start="498800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="195750/3000s" ref="r2" duration="14100/3000s" start="509000/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="209850/3000s" ref="r2" duration="4350/3000s" start="523450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="214200/3000s" ref="r2" duration="8400/3000s" start="529450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="222600/3000s" ref="r2" duration="900/3000s" start="539650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="223500/3000s" ref="r2" duration="50/3000s" start="570350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="223550/3000s" ref="r2" duration="2050/3000s" start="575550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="225600/3000s" ref="r2" duration="3700/3000s" start="585550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="229300/3000s" ref="r2" duration="3350/3000s" start="596250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="232650/3000s" ref="r2" duration="2350/3000s" start="606600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="235000/3000s" ref="r2" duration="1650/3000s" start="609450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="236650/3000s" ref="r2" duration="150/3000s" start="611600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="236800/3000s" ref="r2" duration="1550/3000s" start="627300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="238350/3000s" ref="r2" duration="8550/3000s" start="636200/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="246900/3000s" ref="r2" duration="1050/3000s" start="651650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="247950/3000s" ref="r2" duration="100/3000s" start="658100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="248050/3000s" ref="r2" duration="200/3000s" start="674350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="248250/3000s" ref="r2" duration="3250/3000s" start="733400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="251500/3000s" ref="r2" duration="2100/3000s" start="737350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="253600/3000s" ref="r2" duration="3150/3000s" start="748100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="256750/3000s" ref="r2" duration="1800/3000s" start="778500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="258550/3000s" ref="r2" duration="14050/3000s" start="780650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="272600/3000s" ref="r2" duration="5250/3000s" start="795050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="277850/3000s" ref="r2" duration="3300/3000s" start="801300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="281150/3000s" ref="r2" duration="1150/3000s" start="819400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="282300/3000s" ref="r2" duration="1450/3000s" start="835750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="283750/3000s" ref="r2" duration="6450/3000s" start="838450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="290200/3000s" ref="r2" duration="1200/3000s" start="845500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="291400/3000s" ref="r2" duration="2950/3000s" start="851650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="294350/3000s" ref="r2" duration="16250/3000s" start="855200/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="310600/3000s" ref="r2" duration="200/3000s" start="872250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="310800/3000s" ref="r2" duration="3600/3000s" start="877500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="314400/3000s" ref="r2" duration="4200/3000s" start="883250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="318600/3000s" ref="r2" duration="200/3000s" start="896750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="318800/3000s" ref="r2" duration="5700/3000s" start="902900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="324500/3000s" ref="r2" duration="1450/3000s" start="909250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="325950/3000s" ref="r2" duration="3150/3000s" start="923150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="329100/3000s" ref="r2" duration="300/3000s" start="933200/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="329400/3000s" ref="r2" duration="1150/3000s" start="979850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="330550/3000s" ref="r2" duration="250/3000s" start="985600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="330800/3000s" ref="r2" duration="2700/3000s" start="1020700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="333500/3000s" ref="r2" duration="150/3000s" start="1027550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="333650/3000s" ref="r2" duration="1250/3000s" start="1033100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="334900/3000s" ref="r2" duration="250/3000s" start="1035900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="335150/3000s" ref="r2" duration="1550/3000s" start="1146850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="336700/3000s" ref="r2" duration="250/3000s" start="1151200/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="336950/3000s" ref="r2" duration="2250/3000s" start="1156600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="339200/3000s" ref="r2" duration="12900/3000s" start="1161950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="352100/3000s" ref="r2" duration="2650/3000s" start="1176250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="354750/3000s" ref="r2" duration="19450/3000s" start="1187800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="374200/3000s" ref="r2" duration="250/3000s" start="1209600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="374450/3000s" ref="r2" duration="3150/3000s" start="1217350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="377600/3000s" ref="r2" duration="4450/3000s" start="1220950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="382050/3000s" ref="r2" duration="9050/3000s" start="1225800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="391100/3000s" ref="r2" duration="250/3000s" start="1235700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="391350/3000s" ref="r2" duration="13250/3000s" start="1247600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="404600/3000s" ref="r2" duration="300/3000s" start="1261700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="404900/3000s" ref="r2" duration="7000/3000s" start="1417050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="411900/3000s" ref="r2" duration="1600/3000s" start="1429900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="413500/3000s" ref="r2" duration="200/3000s" start="1446100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="413700/3000s" ref="r2" duration="3750/3000s" start="1451900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="417450/3000s" ref="r2" duration="1650/3000s" start="1492050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="419100/3000s" ref="r2" duration="4900/3000s" start="1494300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="424000/3000s" ref="r2" duration="750/3000s" start="1500700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="424750/3000s" ref="r2" duration="6100/3000s" start="1503700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="430850/3000s" ref="r2" duration="850/3000s" start="1510450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="431700/3000s" ref="r2" duration="16900/3000s" start="1514650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="448600/3000s" ref="r2" duration="10600/3000s" start="1532100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="459200/3000s" ref="r2" duration="6400/3000s" start="1543900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="465600/3000s" ref="r2" duration="3850/3000s" start="1550800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="469450/3000s" ref="r2" duration="4150/3000s" start="1555750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="473600/3000s" ref="r2" duration="4150/3000s" start="1560750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="477750/3000s" ref="r2" duration="2050/3000s" start="1565850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="479800/3000s" ref="r2" duration="7050/3000s" start="1569750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="486850/3000s" ref="r2" duration="14750/3000s" start="1612850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="501600/3000s" ref="r2" duration="6850/3000s" start="1629100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="508450/3000s" ref="r2" duration="3050/3000s" start="1636850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="511500/3000s" ref="r2" duration="300/3000s" start="1643300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="511800/3000s" ref="r2" duration="1900/3000s" start="1665550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="513700/3000s" ref="r2" duration="3900/3000s" start="1668800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="517600/3000s" ref="r2" duration="10400/3000s" start="1679950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="528000/3000s" ref="r2" duration="2500/3000s" start="1691000/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="530500/3000s" ref="r2" duration="3500/3000s" start="1693800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="534000/3000s" ref="r2" duration="12000/3000s" start="1697650/3000s" tcFormat="NDF"/>
</spine>
</sequence>
</project>
</event>
</library>
</fcpxml>
I want to delete all the "asset-clip" elements which has duration less than 1000 so elements like this
<asset-clip name="1x.mp4" offset="54500/3000s" ref="r2" duration="250/3000s" start="205150/3000s" tcFormat="NDF"/>
has duration="250/3000s" and the value before "/" is 250 which is less than 1000 so the whole line will be deleted from my xml. Can some good soul guide me on this python code. Thanks in advance!
CodePudding user response:
Here is XSLT based solution.
It is using a so called Identity Transform pattern.
One single line 2nd template is removing the <asset-clip>
elements that have duration value before "/" less than 1000.
Useful link: How to add DOCTYPE in the target xml using xslt?
XSLT
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="asset-clip[number(substring-before(@duration, '/')) < 1000]"/>
</xsl:stylesheet>
CodePudding user response:
ElementTree based solution below
import xml.etree.ElementTree as ET
MIN_SIZE = 1000
xml = '''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fcpxml>
<fcpxml version="1.9">
<resources>
<format id="r1" name="FFVideoFormat1080p60.0" frameDuration="50/3000s" width="1920" height="1080" colorSpace="1-1-1 (Rec. 709)"/>
<asset id="r2" name="1x.mp4" start="0s" hasVideo="1" format="r1" hasAudio="1" audioSources="1" audioChannels="2" duration="1731150/3000s">
<media-rep kind="original-media" src="file:///Users/shrikant/Desktop/1x.mp4"></media-rep>
</asset>
</resources>
<library>
<event name="auto-editor output">
<project name="1x.mp4">
<sequence format="r1" tcStart="0s" tcFormat="NDF" audioLayout="stereo" audioRate="48k">
<spine>
<asset-clip name="1x.mp4" offset="0s" ref="r2" duration="1400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="1400/3000s" ref="r2" duration="3250/3000s" start="41400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="4650/3000s" ref="r2" duration="4300/3000s" start="74700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="8950/3000s" ref="r2" duration="3850/3000s" start="105950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="12800/3000s" ref="r2" duration="8250/3000s" start="124500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="21050/3000s" ref="r2" duration="3150/3000s" start="148400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="24200/3000s" ref="r2" duration="2150/3000s" start="155850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="26350/3000s" ref="r2" duration="13700/3000s" start="158450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="40050/3000s" ref="r2" duration="6950/3000s" start="189800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="47000/3000s" ref="r2" duration="7500/3000s" start="197150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="54500/3000s" ref="r2" duration="250/3000s" start="205150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="54750/3000s" ref="r2" duration="3350/3000s" start="219150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="58100/3000s" ref="r2" duration="100/3000s" start="229600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="58200/3000s" ref="r2" duration="1500/3000s" start="230100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="59700/3000s" ref="r2" duration="12950/3000s" start="235950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="72650/3000s" ref="r2" duration="22550/3000s" start="266300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="95200/3000s" ref="r2" duration="3650/3000s" start="291050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="98850/3000s" ref="r2" duration="3550/3000s" start="295150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="102400/3000s" ref="r2" duration="4450/3000s" start="299350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="106850/3000s" ref="r2" duration="100/3000s" start="321300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="106950/3000s" ref="r2" duration="6850/3000s" start="328050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="113800/3000s" ref="r2" duration="50/3000s" start="348850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="113850/3000s" ref="r2" duration="10550/3000s" start="349650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="124400/3000s" ref="r2" duration="13600/3000s" start="377400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="138000/3000s" ref="r2" duration="6050/3000s" start="391400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="144050/3000s" ref="r2" duration="11100/3000s" start="397900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="155150/3000s" ref="r2" duration="250/3000s" start="409700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="155400/3000s" ref="r2" duration="3350/3000s" start="414450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="158750/3000s" ref="r2" duration="11700/3000s" start="423850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="170450/3000s" ref="r2" duration="4950/3000s" start="436550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="175400/3000s" ref="r2" duration="1150/3000s" start="442100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="176550/3000s" ref="r2" duration="1250/3000s" start="455950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="177800/3000s" ref="r2" duration="150/3000s" start="459500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="177950/3000s" ref="r2" duration="2350/3000s" start="464050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="180300/3000s" ref="r2" duration="100/3000s" start="467350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="180400/3000s" ref="r2" duration="250/3000s" start="483300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="180650/3000s" ref="r2" duration="13700/3000s" start="484450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="194350/3000s" ref="r2" duration="1400/3000s" start="498800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="195750/3000s" ref="r2" duration="14100/3000s" start="509000/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="209850/3000s" ref="r2" duration="4350/3000s" start="523450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="214200/3000s" ref="r2" duration="8400/3000s" start="529450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="222600/3000s" ref="r2" duration="900/3000s" start="539650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="223500/3000s" ref="r2" duration="50/3000s" start="570350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="223550/3000s" ref="r2" duration="2050/3000s" start="575550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="225600/3000s" ref="r2" duration="3700/3000s" start="585550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="229300/3000s" ref="r2" duration="3350/3000s" start="596250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="232650/3000s" ref="r2" duration="2350/3000s" start="606600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="235000/3000s" ref="r2" duration="1650/3000s" start="609450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="236650/3000s" ref="r2" duration="150/3000s" start="611600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="236800/3000s" ref="r2" duration="1550/3000s" start="627300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="238350/3000s" ref="r2" duration="8550/3000s" start="636200/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="246900/3000s" ref="r2" duration="1050/3000s" start="651650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="247950/3000s" ref="r2" duration="100/3000s" start="658100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="248050/3000s" ref="r2" duration="200/3000s" start="674350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="248250/3000s" ref="r2" duration="3250/3000s" start="733400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="251500/3000s" ref="r2" duration="2100/3000s" start="737350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="253600/3000s" ref="r2" duration="3150/3000s" start="748100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="256750/3000s" ref="r2" duration="1800/3000s" start="778500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="258550/3000s" ref="r2" duration="14050/3000s" start="780650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="272600/3000s" ref="r2" duration="5250/3000s" start="795050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="277850/3000s" ref="r2" duration="3300/3000s" start="801300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="281150/3000s" ref="r2" duration="1150/3000s" start="819400/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="282300/3000s" ref="r2" duration="1450/3000s" start="835750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="283750/3000s" ref="r2" duration="6450/3000s" start="838450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="290200/3000s" ref="r2" duration="1200/3000s" start="845500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="291400/3000s" ref="r2" duration="2950/3000s" start="851650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="294350/3000s" ref="r2" duration="16250/3000s" start="855200/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="310600/3000s" ref="r2" duration="200/3000s" start="872250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="310800/3000s" ref="r2" duration="3600/3000s" start="877500/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="314400/3000s" ref="r2" duration="4200/3000s" start="883250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="318600/3000s" ref="r2" duration="200/3000s" start="896750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="318800/3000s" ref="r2" duration="5700/3000s" start="902900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="324500/3000s" ref="r2" duration="1450/3000s" start="909250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="325950/3000s" ref="r2" duration="3150/3000s" start="923150/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="329100/3000s" ref="r2" duration="300/3000s" start="933200/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="329400/3000s" ref="r2" duration="1150/3000s" start="979850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="330550/3000s" ref="r2" duration="250/3000s" start="985600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="330800/3000s" ref="r2" duration="2700/3000s" start="1020700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="333500/3000s" ref="r2" duration="150/3000s" start="1027550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="333650/3000s" ref="r2" duration="1250/3000s" start="1033100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="334900/3000s" ref="r2" duration="250/3000s" start="1035900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="335150/3000s" ref="r2" duration="1550/3000s" start="1146850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="336700/3000s" ref="r2" duration="250/3000s" start="1151200/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="336950/3000s" ref="r2" duration="2250/3000s" start="1156600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="339200/3000s" ref="r2" duration="12900/3000s" start="1161950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="352100/3000s" ref="r2" duration="2650/3000s" start="1176250/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="354750/3000s" ref="r2" duration="19450/3000s" start="1187800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="374200/3000s" ref="r2" duration="250/3000s" start="1209600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="374450/3000s" ref="r2" duration="3150/3000s" start="1217350/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="377600/3000s" ref="r2" duration="4450/3000s" start="1220950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="382050/3000s" ref="r2" duration="9050/3000s" start="1225800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="391100/3000s" ref="r2" duration="250/3000s" start="1235700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="391350/3000s" ref="r2" duration="13250/3000s" start="1247600/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="404600/3000s" ref="r2" duration="300/3000s" start="1261700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="404900/3000s" ref="r2" duration="7000/3000s" start="1417050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="411900/3000s" ref="r2" duration="1600/3000s" start="1429900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="413500/3000s" ref="r2" duration="200/3000s" start="1446100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="413700/3000s" ref="r2" duration="3750/3000s" start="1451900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="417450/3000s" ref="r2" duration="1650/3000s" start="1492050/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="419100/3000s" ref="r2" duration="4900/3000s" start="1494300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="424000/3000s" ref="r2" duration="750/3000s" start="1500700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="424750/3000s" ref="r2" duration="6100/3000s" start="1503700/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="430850/3000s" ref="r2" duration="850/3000s" start="1510450/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="431700/3000s" ref="r2" duration="16900/3000s" start="1514650/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="448600/3000s" ref="r2" duration="10600/3000s" start="1532100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="459200/3000s" ref="r2" duration="6400/3000s" start="1543900/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="465600/3000s" ref="r2" duration="3850/3000s" start="1550800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="469450/3000s" ref="r2" duration="4150/3000s" start="1555750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="473600/3000s" ref="r2" duration="4150/3000s" start="1560750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="477750/3000s" ref="r2" duration="2050/3000s" start="1565850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="479800/3000s" ref="r2" duration="7050/3000s" start="1569750/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="486850/3000s" ref="r2" duration="14750/3000s" start="1612850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="501600/3000s" ref="r2" duration="6850/3000s" start="1629100/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="508450/3000s" ref="r2" duration="3050/3000s" start="1636850/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="511500/3000s" ref="r2" duration="300/3000s" start="1643300/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="511800/3000s" ref="r2" duration="1900/3000s" start="1665550/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="513700/3000s" ref="r2" duration="3900/3000s" start="1668800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="517600/3000s" ref="r2" duration="10400/3000s" start="1679950/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="528000/3000s" ref="r2" duration="2500/3000s" start="1691000/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="530500/3000s" ref="r2" duration="3500/3000s" start="1693800/3000s" tcFormat="NDF"/>
<asset-clip name="1x.mp4" offset="534000/3000s" ref="r2" duration="12000/3000s" start="1697650/3000s" tcFormat="NDF"/>
</spine>
</sequence>
</project>
</event>
</library>
</fcpxml>'''
def _should_collect_asset(asset):
_duration = int(asset.attrib['duration'].split('/')[0])
return _duration >= MIN_SIZE
root = ET.fromstring(xml)
assets = root.findall('.//asset-clip')
filtered_assets = [a for a in assets if _should_collect_asset(a)]
spine = root.find('.//spine')
spine.clear()
spine.extend(filtered_assets)
CodePudding user response:
In addition to @balderman ElementTree based solution, here's one with lxml:
from lxml import etree
doc = etree.XML([your xml above].encode())
for duration in doc.xpath('//asset-clip'):
if (int(duration.xpath('./@duration')[0].split('/')[0])<1000):
duration.getparent().remove(duration)