hi

I am (trying to) adding a new feature in the reencoding server : the
ability to specify a slice of the original program to be reencoded (by
specifying start and end , using bookmarks)

unfortunately it does not work , and I do not understand why : looking
into the log of the encodingserver , I see that indeed the
encodingserver is scheduling the mencoder job using appropriate -ss and
-endpos commands... but then each of this queued jobs lasts just a
fraction of a second

how do I get more logging and debugging output out of the encoding server ?

thanks

a.

ps: I attach my current code, just for a reference
--- /usr/src/freevo/freevo-1.7.0/src/./video/plugins/reencode2.py	2007-02-03 19:08:40.000000000 +0100
+++ ./video/plugins/reencode2.py	2007-03-25 14:35:06.000000000 +0200
@@ -34,6 +34,7 @@
 from os.path import join, split
 import plugin
 import menu
+import util
 import os
 import config
 from video.encodingclient import *
@@ -58,6 +59,7 @@
         self.source = ''
         self.output = ''
         self.profile = {}
+        self.timeslice = [ None, None ]
         self.profile['container'] = config.REENCODE_CONTAINER
         self.profile['resolution'] = config.REENCODE_RESOLUTION
         self.profile['videocodec'] = config.REENCODE_VIDEOCODEC
@@ -75,7 +77,7 @@
         _debug_('config(self)', 1)
         return [
             ('REENCODE_CONTAINER', 'avi', 'Container type'),
-            ('REENCODE_RESOLUTION', 'Optimal', 'Container type'),
+            ('REENCODE_RESOLUTION', 'Optimal', 'Resolution'),
             ('REENCODE_VIDEOCODEC', 'XviD', 'Video codec'),
             ('REENCODE_VIDEOBITRATE', '800', 'Video bit rate'),
             ('REENCODE_AUDIOCODEC', 'MPEG 1 Layer 3 (mp3)', 'Audio codec'),
@@ -138,6 +140,8 @@
         menu_items += [ menu.MenuItem(_('Start Encoding'), self.create_job, self.profile) ] 
         menu_items += [ menu.MenuItem(_('Select Encoding Profile'), action=self.select_profile) ]
         menu_items += [ menu.MenuItem(_('Modify Container'), action=self.mod_container) ]
+        menu_items += [ menu.MenuItem(_('Modify Start Time'), action=self.mod_start_time) ]
+        menu_items += [ menu.MenuItem(_('Modify End Time'), action=self.mod_end_time) ]
         menu_items += [ menu.MenuItem(_('Modify Resolution'), action=self.mod_resolution) ]
         menu_items += [ menu.MenuItem(_('Modify Video Codec'), action=self.mod_videocodec) ]
         menu_items += [ menu.MenuItem(_('Modify Video Bitrate'), action=self.mod_videobitrate) ]
@@ -161,6 +165,40 @@
         menuw.pushmenu(encoding_menu)
         menuw.refresh()
 
+    def __select_time(self, arg=None, menuw=None, which=None):
+        bookmarkfile = util.get_bookmarkfile(self.item.filename)
+        if not os.path.exists(bookmarkfile):
+            self.error(_('No bookmarks are set for this video'))
+            return
+        menu_items = [ menu.MenuItem(_('Start time'), action=which, arg=0) , ]
+        for line in util.readfile(bookmarkfile):
+            sec = int(line)
+            hour = int(sec/3600)
+            min = int((sec-(hour*3600))/60)
+            time = '%0.2d:%0.2d:%0.2d' % (hour,min,sec % 60)
+            menu_items += [ menu.MenuItem(time, action=which, arg=sec) ]
+        menu_items += [ menu.MenuItem(_('Do not set'), action=which, arg=None) , ]
+        encoding_menu = menu.Menu(_('Select Time'), menu_items, item_types = 'video encoding menu')
+        encoding_menu.infoitem = self
+        menuw.pushmenu(encoding_menu)
+        menuw.refresh()
+
+    def set_start_time(self, arg=None, menuw=None):
+        self.timeslice[0] = arg
+        if menuw:
+            menuw.back_one_menu(arg='reload')
+    
+    def set_end_time(self, arg=None, menuw=None):
+        self.timeslice[1] = arg
+        if menuw:
+            menuw.back_one_menu(arg='reload')
+    
+    def mod_start_time(self, arg=None, menuw=None):
+        self.__select_time(arg, menuw, self.set_start_time)
+        
+    def mod_end_time(self, arg=None, menuw=None):
+        self.__select_time(arg, menuw, self.set_end_time)
+
     def mod_container(self, arg=None, menuw=None):
         _debug_('mod_container(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
@@ -331,6 +369,12 @@
 
         idnr = resp
 
+        (status, resp) = setTimeslice(idnr, self.timeslice)
+        _debug_('setTimeslice:status:%s resp:%s' % (status, resp))
+        if not status:
+            self.error(resp)
+            return
+
         (status, resp) = setContainer(idnr, profile['container'])
         _debug_('setContainer:status:%s resp:%s' % (status, resp))
         if not status:
--- /usr/src/freevo/freevo-1.7.0/src/./video/encodingclient.py	2006-12-27 15:02:48.000000000 +0100
+++ ./video/encodingclient.py	2007-03-25 13:55:53.000000000 +0200
@@ -145,6 +145,13 @@
         return (False, 'EncodingClient: connection error')
     
     return returnFromJelly(status, response)
+
+def setTimeslice(idnr, timeslice):
+    try:
+        (status, response) = server.setTimeslice(idnr, timeslice)
+    except:
+        return (False, 'EncodingClient: connection error')
+    return (status, response)
     
 def setContainer(idnr, container):
     """Set a container format
--- /usr/src/freevo/freevo-1.7.0/src/./encodingcore.py	2007-01-22 22:43:02.000000000 +0100
+++ ./encodingcore.py	2007-03-25 14:16:25.000000000 +0200
@@ -131,6 +131,10 @@
         self.vfilters = []
         self.crop = None
 
+        ## list of initial and end point of slice to encode 
+        self.timeslice = [ None , None ]
+        ##corresponding arguments for mencoder
+        self.timeslice_mencoder = []
 
         self.acodec = AudioCodecList[0]
         self.abrate = 128
@@ -153,6 +157,22 @@
         self.finishedanalyze = False
         self._AnalyzeSource()
 
+    def setTimeslice(self, timeslice):
+        "Set the encoding timeslice"
+        self.timeslice = timeslice
+        assert(type(timeslice) == type([]))
+        assert(len(timeslice) == 2)
+        self.timeslice_mencoder = []
+        start=0
+        if timeslice[0] :
+            self.timeslice_mencoder += [ '-ss %d' % timeslice[0],]
+            start = timeslice[0]
+        if timeslice[1] :
+            self.timeslice_mencoder += ['-endpos %d' % (timeslice[1]-start) ]
+            if timeslice[1] < start:
+                self.timeslice_mencoder = []
+                self.timeslice = [ None , None ]
+                return 'Invalid slice of times: end is before start ??'
 
     def setContainer(self, container):
         """Set a container to hold the audio & video streams"""
@@ -268,12 +288,17 @@
         Function is always called because cropping is a good thing, and we can pass our ideal values
         back to the client wich can verify them visually if needed.""" #not true atm
         #build mplayer parameters
-        if hasattr(self, "length"):
-            sstep = int(self.length / 27)
+        start = 0
+        if self.timeslice[0] :
+            start = self.timeslice[0]
+        if self.timeslice[1] :
+            sstep = int( (end - start) / 27)
+        elif hasattr(self, "length"):
+            sstep = int( (self.length - start) / 27)
         else:
             sstep = 60
 
-        arguments = [ "-vop", "cropdetect=30", "-nosound", "-vo", "null", "-frames", "10", "-sstep", str(sstep)]
+        arguments = self.timeslice_mencoder + [ "-vf", "cropdetect=30", "-nosound", "-vo", "null", "-frames", "25", "-sstep", str(sstep)]
 
         if self.sourcetype == "dvd":
             arguments += [ '-dvd-device', self.source, 'dvd://%s' % self.chapter ]
@@ -330,14 +355,14 @@
     def _GCLMAudiopass(self):
         """Returns audio pass specefic part of mencoder cl"""
         if self.acodec == 'iPoda':
-            return [
+            return self.timeslice_mencoder + [
                 "-ovc", MencoderMapping[self.acodec][0],
                 "-oac", MencoderMapping[self.acodec][1],
                     MencoderMapping[self.acodec][2][0], MencoderMapping[self.acodec][2][1] % self.abrate,
                     MencoderMapping[self.acodec][3][0], MencoderMapping[self.acodec][3][1],
                 "-o", "frameno.avi"]
         else:
-            return [
+            return self.timeslice_mencoder + [
                 "-ovc", MencoderMapping[self.acodec][0],
                 "-oac", MencoderMapping[self.acodec][1],
                         MencoderMapping[self.acodec][2][0], MencoderMapping[self.acodec][2][1] % self.abrate,
@@ -423,6 +448,8 @@
         if yscaled:
             args += ["-sws", "1"]
 
+        args = self.timeslice_mencoder + args
+
         return args
 
 
--- /usr/src/freevo/freevo-1.7.0/src/./helpers/encodingserver.py	2006-12-27 15:02:48.000000000 +0100
+++ ./helpers/encodingserver.py	2007-03-25 12:19:55.000000000 +0200
@@ -136,7 +136,15 @@
             return (True, "EncodingServer::setContainer: OK")
         else:
             return (False, "EncodingServer::setContainer: %s" % status)
-            
+
+    def xmlrpc_setTimeslice(self,idnr,timeslice):
+        _debug_("xmlrpc_setTimeslice(self, %s, %s)" % (idnr, timeslice), 3)
+        status = self.jobs[idnr].setTimeslice(timeslice)
+        if not status:
+            return (True, "EncodingServer::setTimeslice: OK")
+        else:
+            return (False, "EncodingServer::setTimeslice: %s" % status)
+    
     def xmlrpc_getVideoCodecCAP(self, idnr):
         _debug_("xmlrpc_getVideoCodecCAP(self, idnr)", 3)
         return (True, jam(self.jobs[idnr].getVideoCodecList()))

Attachment: signature.asc
Description: OpenPGP digital signature

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to