Skip to content

Commit

Permalink
feat!: new format for <video-segment> and <audio-segment> (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum authored Aug 22, 2024
1 parent 4d2f98a commit 1db2c27
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
11 changes: 11 additions & 0 deletions import_project.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@
"cardinality": "0-n"
}
]
},
{
"name": "VideoObject",
"labels": {"en": "Video object"},
"super": "MovingImageRepresentation",
"cardinalities": [
{
"propname": ":hasName",
"cardinality": "0-n"
}
]
}
]
}
Expand Down
22 changes: 22 additions & 0 deletions import_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,28 @@ def main() -> None:
)
root.append(link)


# Video with a Segment
# --------------------
# Videos and audios are normal resources...
video = excel2xml.make_resource("Publicly available video", ":VideoObject", "video_1")
video.append(excel2xml.make_bitstream_prop("videos/my_video.mp4"))
root.append(video)

# ... but the segments behave differently:
segment = excel2xml.make_video_segment("The first 5 seconds of my video", "segment_1")
segment.append(excel2xml.make_isSegmentOf_prop("video_1"))
segment.append(excel2xml.make_hasSegmentBounds_prop(segment_start=0, segment_end=5))
segment.append(excel2xml.make_hasTitle_prop("Intro of my video"))
segment.append(excel2xml.make_hasComment_prop("Video segments can also have comments"))
segment.append(excel2xml.make_hasDescription_prop("This segments spans the first 5 seconds of my video"))
segment.append(excel2xml.make_hasKeyword_prop("publicly available video"))
segment.append(excel2xml.make_relatesTo_prop(object_labels_to_ids["Horohoroto"]))
root.append(segment)

# audio segments are identical, just replace "video" by "audio"


# write file
# ----------
excel2xml.write_xml(root, "data-processed.xml")
Expand Down
12 changes: 12 additions & 0 deletions test/expected.xml
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,16 @@
<resptr permissions="prop-default">Horohoroto_5652b411-2c50-4086-896c-23b208ea27a8</resptr>
</resptr-prop>
</link>
<resource label="Publicly available video" restype=":VideoObject" id="video_1" permissions="res-default">
<bitstream permissions="prop-default">videos/my_video.mp4</bitstream>
</resource>
<video-segment label="The first 5 seconds of my video" id="segment_1" permissions="res-default">
<isSegmentOf permissions="prop-default">video_1</isSegmentOf>
<hasSegmentBounds segment_start="0" segment_end="5" permissions="prop-default"/>
<hasTitle permissions="prop-default">Intro of my video</hasTitle>
<hasComment permissions="prop-default">Video segments can also have comments</hasComment>
<hasDescription permissions="prop-default">This segments spans the first 5 seconds of my video</hasDescription>
<hasKeyword permissions="prop-default">publicly available video</hasKeyword>
<relatesTo permissions="prop-default">Horohoroto_42fd3508-f299-4981-9d85-65a48cab14d7</relatesTo>
</video-segment>
</knora>
Binary file added videos/my_video.mp4
Binary file not shown.

0 comments on commit 1db2c27

Please sign in to comment.