Skip to content

Commit

Permalink
Add opencast#18, script to simulate ingestion of multiple types of me…
Browse files Browse the repository at this point in the history
…diapackages
  • Loading branch information
JamesUoM committed Oct 24, 2018
1 parent c1ddecf commit 25eb95d
Show file tree
Hide file tree
Showing 9 changed files with 515 additions and 0 deletions.
12 changes: 12 additions & 0 deletions simulate-ingests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Opencast Simulate Ingests
Simulate ingesting of recordings of using multiple mediapackage profiles.

## Requirements

* depends on python-jinja2, python-requests
* appropriate presentation and presenter tracks in that match the mediapackage profiles,
see mediapackages/tracks/README.md for suggestions on how to locate suitable data.

## Configuration

Copy simulation-example.properties to simulation.properties and edit according to the comments.
1 change: 1 addition & 0 deletions simulate-ingests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__author__ = 'andrew wilson, james perrin'
9 changes: 9 additions & 0 deletions simulate-ingests/mediapackages/templates/episode.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version='1.0' encoding='UTF-8'?>
<dublincore xmlns="http://www.opencastproject.org/xsd/1.0/dublincore/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance/">
<dcterms:created>{{ created }}</dcterms:created>
<dcterms:identifier>{{ identifier }}</dcterms:identifier>
<dcterms:title>{{ title }}</dcterms:title>
<dcterms:isPartOf>{{ is_part_of }}</dcterms:isPartOf>
<dcterms:source>{{ source }}</dcterms:source>
<dcterms:spatial>{{ location }}</dcterms:spatial>
</dublincore>
48 changes: 48 additions & 0 deletions simulate-ingests/mediapackages/templates/manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?xml version='1.0' encoding='UTF-8'?>
<mediapackage xmlns="http://mediapackage.opencastproject.org" duration="{{ duration }}" id="{{ identifier }}" start="{{ created }}">
<media>
{%- if has_presentation_video %}
<track id="track-0" type="presentation/source">
<mimetype>video/{{ video_mime }}</mimetype>
<url>presentation.{{ video_ext }}</url>
<duration>{{ duration }}</duration>
</track>
{% endif -%}
{%- if has_presenter_video %}
<track id="track-1" type="presenter/source">
<mimetype>video/{{ video_mime }}</mimetype>
<url>presenter.{{ video_ext }}</url>
<duration>{{ duration }}</duration>
</track>
{% endif -%}
{%- if has_presentation_audio %}
<track id="track-2" type="presentation/source">
<mimetype>audio/{{ audio_mime }}</mimetype>
<url>presentation.{{ audio_ext }}</url>
<duration>{{ duration }}</duration>
</track>
{% endif -%}
{%- if has_presenter_audio %}
<track id="track-3" type="presenter/source">
<mimetype>audio/{{ audio_mime }}</mimetype>
<url>presenter.{{ audio_ext }}</url>
<duration>{{ duration }}</duration>
</track>
{% endif %}
</media>
<metadata>
<catalog id="catalog-0" type="dublincore/episode">
<mimetype>text/xml</mimetype>
<url>episode.xml</url>
</catalog>
<catalog id="catalog-1" type="dublincore/series">
<mimetype>text/xml</mimetype>
<url>series.xml</url>
</catalog>
</metadata>
<attachments>
<attachment id="org.opencastproject.capture.agent.properties">
<url>org.opencastproject.capture.agent.properties</url>
</attachment>
</attachments>
</mediapackage>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
event.location={{ location }}
event.series={{ series_id }}
event.title={{ title }}
org.opencastproject.workflow.definition={{ workflow }}
org.opencastproject.workflow.config.emailAddresses={{ email }}
org.opencastproject.workflow.config.publishToOaiPmh={{ publish }}
org.opencastproject.workflow.config.editRecording={{ edit }}
7 changes: 7 additions & 0 deletions simulate-ingests/mediapackages/templates/series.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<dublincore xmlns="http://www.opencastproject.org/xsd/1.0/dublincore/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:oc="http://www.opencastproject.org/matterhorn/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<dcterms:title>{{ title }}</dcterms:title>
<dcterms:created xsi:type="dcterms:W3CDTF">{{ created }}</dcterms:created>
<dcterms:source>{{ source }}</dcterms:source>
<oc:annotation>false</oc:annotation>
<dcterms:identifier>{{ identifier }}</dcterms:identifier>
</dublincore>
46 changes: 46 additions & 0 deletions simulate-ingests/mediapackages/tracks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Mediapackage Tracks Directory
Video and audio tracks should be present here that match the tracks listed in the mediapackage
profiles. The filenames must have the form:

[presenation|presenter]-<type>-<duration>.[avi|mp3]

e.g

presenter-single-1.avi

## Filtering Sample Mediapackage from Database

Analysing the mediapackage xml in the archive is expensive, therefore create a temporary table (#tablename) for
selecting prospective tracks:

/* create temp table */
with xmlnamespaces (default 'http://mediapackage.opencastproject.org')
select
id,
mp.value('(/mediapackage/media/track/@type)[1]', 'varchar(256)') as track_1,
left(mp.value('(/mediapackage/media/track/mimetype)[1]', 'varchar(256)'), 5) as mime_1,
mp.value('(/mediapackage/media/track/@type)[2]', 'varchar(256)') as track_2,
left(mp.value('(/mediapackage/media/track/mimetype)[2]', 'varchar(256)'), 5) as mime_2,
mp.value('(/mediapackage/media/track/@type)[3]', 'varchar(256)') as track_3,
left(mp.value('(/mediapackage/media/track/mimetype)[3]', 'varchar(256)'), 5) as mime_3,
mp.value('(/mediapackage/@duration)[1]', 'int')/60000 as duration
into #mp_data
from
/* Cast the xml strings to UTF-16 encoded xml fields */
(select id, cast(replace(cast(mediapackage_xml as nvarchar(max)), 'UTF-8', 'UTF-16') as xml) as mp
from dbo.mh_archive_episode
/* Pre filter the data */
where modification_date > '2017-01-10 00:00:00'
and version = 0 and deleted = 0) as mpxml;
Once the temporary table #mp_data has been created queries can be run against it get ids of prospective example
mediapackages:

select id
from #mp_data
where
duration=55
and track_1='presenter/source' and mime_1='video'
and track_2='presenter/source' and mime_2='audio'
and track_3 is null and mime_3 is null;

Loading

0 comments on commit 25eb95d

Please sign in to comment.