[xiph-commits] r3209 - in arkaiv/trunk: . arkaiv/controllers arkaiv/model arkaiv/templates data/templates

dcrowdy at svn.annodex.net dcrowdy at svn.annodex.net
Wed Aug 29 05:28:49 PDT 2007


Author: dcrowdy
Date: 2007-08-29 05:28:49 -0700 (Wed, 29 Aug 2007)
New Revision: 3209

Removed:
   arkaiv/trunk/arkaiv/controllers/play.py
Modified:
   arkaiv/trunk/arkaiv/controllers/page.py
   arkaiv/trunk/arkaiv/controllers/page.pyc
   arkaiv/trunk/arkaiv/model/cmmlparser.py
   arkaiv/trunk/arkaiv/model/cmmlparser.pyc
   arkaiv/trunk/arkaiv/templates/displayitem.mak
   arkaiv/trunk/data/templates/displayitem.mak.py
   arkaiv/trunk/data/templates/displayitem.mak.pyc
   arkaiv/trunk/production.ini
Log:
Images added to clips display for video - using mplayer (messy...)



Modified: arkaiv/trunk/arkaiv/controllers/page.py
===================================================================
--- arkaiv/trunk/arkaiv/controllers/page.py	2007-08-29 05:26:52 UTC (rev 3208)
+++ arkaiv/trunk/arkaiv/controllers/page.py	2007-08-29 12:28:49 UTC (rev 3209)
@@ -15,6 +15,7 @@
 import shutil
 import annodex
 import logging
+import subprocess
 from string import split
 from socket import *
 from arkaiv.controllers import *
@@ -128,12 +129,16 @@
         urlpath = split(cmmlfile, path_base)
         # Now split off the extension
         urlpath = os.path.splitext(urlpath[1])[0]
+#        clipimagepath = urlpath + "_clipimages"
+        clipimageurl = media_url_base + os.path.dirname(urlpath) + "/"
+#        print clipimageurl
+#        print "urlpath: " + urlpath
         url = media_url_base + urlpath + ".anx"
         if c.playclip=="":
             sourcedict['urlpath'] = url 
         else:
             sourcedict['urlpath'] = url + "?id=" + c.playclip
-
+        sourcedict['clipimageurl'] = clipimageurl
         # now get some source info:
         o = OggzInfo(oggsource)
        	sourcedict['duration'] = o.duration()
@@ -214,13 +219,43 @@
         clip['a_text'] = request.params['a_text']
         clip['id'] = request.params['id']
         clip['a_href'] = request.params['a_href']
-        clip['img_src'] = request.params['img_src']
         clip['desc'] = request.params['desc']
+        has_video = request.params['hasvideo']
+
+        # first get the source file info
+        cmmlfile = model.getitemcmmlfile(clip['itemid'])
+
+        # create an image to display for the clip
+        if has_video == "Yes":
+            basename = os.path.splitext(cmmlfile)[0]
+            imagedirname = basename + "_clipimages"
+    
+            oggsource = model.getsourcepath(clip['itemid'])
+    
+            # create an image using mplayer
+            cmd = "mplayer -vo png:z=6 -vf scale -zoom -xy 96 -ao null -ss '" + str(clip['starttime']) + "' -frames 2 " + oggsource 
+            cwd = os.getcwd()
+            os.chdir(imagedirname)
+            
+            runit = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE
+    , stderr=subprocess.PIPE)
+            out, err = runit.communicate()
+            # and the file we want will be called 00000002.png...
+            # so rename to something more descriptive
+            clipimagename = str(clip['starttime']) + ".png"
+            shutil.move("00000002.png", clipimagename)
+            os.chdir(cwd)   # very ugly... better image creation needed allround really.
+     
+            # add that info to the dictionary - only needs to be a relative location
+            relpath = os.path.split(imagedirname)[1]
+            clip['img_src'] = relpath + "/" + clipimagename 
+        else:
+            clip['img_src'] = ""
+
         model.addclip(clip)
         # Now the same information added to the cmml file
         # Clips need to be in temporal order so redo the whole lot
         # Get a list of clip dictionary objects
-        cmmlfile = model.getitemcmmlfile(clip['itemid'])
         cliplist = model.getclipinfoforitem(clip['itemid'])
         parser = cmmlParser()
         parser.addclipstocmmlfile(cmmlfile, cliplist)
@@ -277,13 +312,28 @@
         oggsource.file.close()
         permanent_file.close()
 
+        basename = os.path.splitext(newoggname)[0]
+        imagedirname = basename + "_clipimages"
+        # Create a directory for clip images
+#        print imagedirname
+        if not os.path.isdir(imagedirname):
+            os.makedirs(imagedirname, mode=0755)
+
+#        cmd = "mplayer -vo png:z=6 -vf scale -zoom -xy 96 -ao null -ss '1000' -frames 2 " + newoggname 
+#        cwd = os.getcwd()
+#        os.chdir(imagedirname)
+#
+#        runit = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE
+#, stderr=subprocess.PIPE)
+#        out, err = runit.communicate()
+#        os.chdir(cwd)   # very ugly... better image creation needed allround really.
+                
         # Get the title for the item (head title)
         parser = cmmlParser()
         parser.setcmmlfilename(newcmmlname)
         title = parser.gettitle(newcmmlname) 
         # adding an item here, even though we don't actually have the source
         # anx file in place yet...
-        basename = os.path.splitext(newoggname)[0]
         newanxname = basename + ".anx"
         newitemid = model.addsource(title, newoggname, newcmmlname)
 

Modified: arkaiv/trunk/arkaiv/controllers/page.pyc
===================================================================
(Binary files differ)

Deleted: arkaiv/trunk/arkaiv/controllers/play.py
===================================================================
--- arkaiv/trunk/arkaiv/controllers/play.py	2007-08-29 05:26:52 UTC (rev 3208)
+++ arkaiv/trunk/arkaiv/controllers/play.py	2007-08-29 12:28:49 UTC (rev 3209)
@@ -1,58 +0,0 @@
-import logging
-import annodex
-import sys
-
-from arkaiv.lib.base import *
-
-log = logging.getLogger(__name__)
-
-class PlayController(BaseController):
-
-    def index(self):
-        # Return a rendered template
-        #   return render('/some/template.html')
-        # or, Return a response
-        print "Do we even get here?"
-        return 'Hello World'
-
-    def playit(self):
-        def content_type (ct):
-            print "Content-Type: %s" % ct
-
-        def flush_headers ():
-            print
-            sys.stdout.flush()
-
-        def blat(anx):
-           while 1:
-               x = anx.write(1024000)
-               yield x
-               if (x <= 0):
-                   break
-        
-        content_type ("application/x-annodex")
-
-        print "playit"
-        myfile = request.params['filetoplay']
-        itemid = request.params['itemid']
-#        print myfile
-        print itemid
-        # get source file
-        sourceid = model.getsourcesforitem(itemid)
-        sourcepath = model.getsourcepath(sourceid)
-        print sourcepath
-        annodex.init_importers("*/*")
-        anx = annodex.Anx(1, "w")
-        anx.writer_import(sourcepath)
-        try:
-            duration = anx.get_duration()
-            if (duration != -1):
-                print ("X-Content-Duration: %f" % (anx.get_duration()))
-        except AttributeError:
-            pass
-#
-#        flush_headers()
-# Clips to be added in here
-        
-#        sys.stdout.flush()
-        return blat(anx)

Modified: arkaiv/trunk/arkaiv/model/cmmlparser.py
===================================================================
--- arkaiv/trunk/arkaiv/model/cmmlparser.py	2007-08-29 05:26:52 UTC (rev 3208)
+++ arkaiv/trunk/arkaiv/model/cmmlparser.py	2007-08-29 12:28:49 UTC (rev 3209)
@@ -141,6 +141,8 @@
             newclip.set('id', clip['id'])
             newclip.set('start', str(clip['start_time']))
             newclip.set('id', clip['id'])
+            img = Etree.SubElement(newclip, 'img')
+            img.set('src', clip['img_src'])
             desc = Etree.SubElement(newclip, 'desc')
             desc.text = clip['desc']
         

Modified: arkaiv/trunk/arkaiv/model/cmmlparser.pyc
===================================================================
(Binary files differ)

Modified: arkaiv/trunk/arkaiv/templates/displayitem.mak
===================================================================
--- arkaiv/trunk/arkaiv/templates/displayitem.mak	2007-08-29 05:26:52 UTC (rev 3208)
+++ arkaiv/trunk/arkaiv/templates/displayitem.mak	2007-08-29 12:28:49 UTC (rev 3209)
@@ -144,7 +144,7 @@
 </tr>
 % for clipinfo in c.cliplist:
 <tr>
-   <td><a onclick="javascript:SetLocation('${c.sourcedict['urlpath']}?id=${clipinfo['id']}')"><img width=60 height=40 src="/images/blank.png"></a></td>
+   <td><a onclick="javascript:SetLocation('${c.sourcedict['urlpath']}?id=${clipinfo['id']}')"><img src="${c.sourcedict['clipimageurl']}${clipinfo['img_src']}"></a></td>
     <td>${clipinfo['start_time']}</td>
     <td>${clipinfo['id']}</td>
     <td>${clipinfo['desc']}</td>
@@ -186,6 +186,7 @@
 </table>
 ${ h.hidden_field('headindex', value = c.headdict['ixh']) }
 ${ h.hidden_field('itemid', value=c.itemid) }
+${ h.hidden_field('hasvideo', value=c.sourcedict['has_video']) }
 
 ${ h.submit('Add') } 
 ${ h.end_form() } 

Modified: arkaiv/trunk/data/templates/displayitem.mak.py
===================================================================
--- arkaiv/trunk/data/templates/displayitem.mak.py	2007-08-29 05:26:52 UTC (rev 3208)
+++ arkaiv/trunk/data/templates/displayitem.mak.py	2007-08-29 12:28:49 UTC (rev 3209)
@@ -1,7 +1,7 @@
 from mako import runtime, filters, cache
 UNDEFINED = runtime.UNDEFINED
 _magic_number = 2
-_modified_time = 1188364632.2161951
+_modified_time = 1188390221.0295939
 _template_filename='/home/dcrowdy/src/working/test/arkaiv/trunk/arkaiv/templates/displayitem.mak'
 _template_uri='/displayitem.mak'
 _template_cache=cache.Cache(__name__, _modified_time)
@@ -145,7 +145,10 @@
             context.write(unicode(c.sourcedict['urlpath']))
             context.write(u'?id=')
             context.write(unicode(clipinfo['id']))
-            context.write(u'\')"><img width=60 height=40 src="/images/blank.png"></a></td>\n    <td>')
+            context.write(u'\')"><img src="')
+            context.write(unicode(c.sourcedict['clipimageurl']))
+            context.write(unicode(clipinfo['img_src']))
+            context.write(u'"></a></td>\n    <td>')
             # SOURCE LINE 148
             context.write(unicode(clipinfo['start_time']))
             context.write(u'</td>\n    <td>')
@@ -201,11 +204,14 @@
         context.write(u'\n')
         # SOURCE LINE 188
         context.write(unicode( h.hidden_field('itemid', value=c.itemid) ))
+        context.write(u'\n')
+        # SOURCE LINE 189
+        context.write(unicode( h.hidden_field('hasvideo', value=c.sourcedict['has_video']) ))
         context.write(u'\n\n')
-        # SOURCE LINE 190
+        # SOURCE LINE 191
         context.write(unicode( h.submit('Add') ))
         context.write(u' \n')
-        # SOURCE LINE 191
+        # SOURCE LINE 192
         context.write(unicode( h.end_form() ))
         context.write(u' \n</div>\n<script>\nvar plugin = document.embeds[0];\nvar input  = document.api.ifield;\nvar goto  = document.api.gotofield;\nvar output = document.api.ofield;\n\nfunction Play() {\n  plugin.play();\n  addOutput("Play!");\n}\n\nfunction Pause() {\n  plugin.pause();\n  addOutput("Pause!");\n}\n\nfunction SetLocation(location) {\n//  plugin.setPlayPosition(location);\n  plugin.setCurrentMovie(location);\n  addOutput("Current movie: " + plugin.getCurrentMovie());\n  addOutput("setting a location: " + location + " ms");\n}\n\nfunction GetPlayPosition() {\n  addOutput("Play position: " + plugin.getPlayPosition() + " ms");\n}\n\nfunction skip(dir) {\n//    addOutput("we get here")\n    i = getInput();\n    addOutput("i is " + i);\n    if (i <= 0) i = 1000;\n    addOutput("dir is " + dir);\n    t = plugin.getPlayPosition() + (i * dir);\n    addOutput("t is " + t);\n    addOutput("Skipping by " + i + " to " + t + " ms - " +\n            (plugin.setPlayPositi
 on(t) ? "succeeded" : "failed"));\n}\n\nfunction getInput() {\n  i = parseInt(input.value);\n  return isNaN(i) ? 0 : i;\n}\n\nfunction getGoto() {\n  i = parseInt(goto.value);\n  return isNaN(i) ? 0 : i;\n}\n\n\nfunction GotoPosition() {\n  i = getGoto();\n  i = i * 1000;\n  plugin.setPlayPosition(i);\n}\n\nvar outLines = 0;\n\nfunction addOutput(str) {\n  if (outLines == 0) {\n    output.value = str;\n  } else {\n    output.value = str + "\\n" + output.value;\n  }\n  outLines++;\n  if (outLines == 11) {\n    i = output.value.lastIndexOf("\\n");\n    output.value = output.value.substr(0, i);\n    outLines--;\n  }\n}\n</script>\n\n')
         return ''

Modified: arkaiv/trunk/data/templates/displayitem.mak.pyc
===================================================================
(Binary files differ)

Modified: arkaiv/trunk/production.ini
===================================================================
--- arkaiv/trunk/production.ini	2007-08-29 05:26:52 UTC (rev 3208)
+++ arkaiv/trunk/production.ini	2007-08-29 12:28:49 UTC (rev 3209)
@@ -26,7 +26,7 @@
 sqlalchemy.echo = true
 authkit.enable = true
 authkit.method = digest
-authkit.users.setup = dcrowdy:hoohaa
+authkit.users.setup = user:pylons
 
 
 # If you'd like to fine-tune the individual locations of the cache data dirs



More information about the commits mailing list