Working with Static Views

You can post here general questions about Advene in english.

Working with Static Views

Post by cinematicity » Mon Feb 06, 2012 2:08 pm

I have a question about static views.

I've created a very simple static view to summarize my annotations and include a thumbnail for each one. I'm impressed that i can generate a customized summary and view it in a web browser -- very cool. The part of the HTML template to produce the thumbnail looks like this:

Code: Select all
<img class="screenshot" tal:attributes="src a/snapshot_url" />

And the resulting HTML looks like this:

Code: Select all
<img src="/packages/My_Movie/imagecache/1532449" class="screenshot" />


I don't really understand the TALES part of this, but it looks like the thumbnail is generated from start point of the annotation.

If possible, I would like to have the thumbnail come from the middle of the annotation rather than the beginning.

Is there a way to do this?

The only thing I can figure is that I might be able to embed some Python code into the template that calculates the difference between the stop and start points, and then computes a frame number in the middle of the sequence. It looks like Advene will generate a jpeg of any frame if I just refresh the browser. Am not sure on the details here, though.

Any suggestions?
cinematicity
Posts: 31
Joined: Sun Jan 16, 2011 7:18 am

Re: Working with Static Views

Post by oaubert » Mon Feb 06, 2012 8:19 pm

You are on the right track. The snapshot_url method (which returns the appropriate URL to reference a snapshot of the video) applies to either an annotation (and uses its begin timecode), but also to integers. You can compute (through a python: expression) the mean of begin/end, and use this value as parameter to snapshot_url:

Code: Select all
<img tal:define="mean python:(a.fragment.begin+a.fragment.end)/2" tal:attributes="src mean/snapshot_url" />


Just to open another option: if you want to have more control on the timestamp used to generate the snapshot, you can define another annotation type and a relation type called e.g. "snapshot_reference" for instance. For each annotation for which you want to specify a precise snapshot, create another annotation in the new annotation type and link it with the first annotation, using the "snapshot_reference" relation. Then, the following code:
Code: Select all
<img tal:define="ref a/typedRelatedOut/snapshot_reference/first | a" tal:attributes="src ref/snapshot_url" />

will use the begin time of the related annotation (if there is one), and else fallback to the begin time of the annotation itself.
oaubert
Site Admin
Posts: 88
Joined: Mon Jan 07, 2008 4:02 pm

Re: Working with Static Views

Post by cinematicity » Tue Feb 07, 2012 1:44 am

That works great, thanks!
cinematicity
Posts: 31
Joined: Sun Jan 16, 2011 7:18 am


Return to English questions