Author: duncan
Date: Sun Jan 20 07:48:33 2008
New Revision: 10299

Log:
[ 1875159 ] Continued improvement/ refactoring of encodingcore
Patch from Jonathan Isom applied


Modified:
   branches/rel-1-7/freevo/freevo_config.py
   branches/rel-1-7/freevo/src/encodingcore.py
   branches/rel-1-7/freevo/src/helpers/encodingserver.py
   branches/rel-1-7/freevo/src/video/encodingclient.py
   branches/rel-1-7/freevo/src/video/plugins/dvdbackup.py
   branches/rel-1-7/freevo/src/video/plugins/reencode.py
   branches/rel-1/freevo/freevo_config.py
   branches/rel-1/freevo/src/encodingcore.py
   branches/rel-1/freevo/src/helpers/encodingserver.py
   branches/rel-1/freevo/src/video/encodingclient.py
   branches/rel-1/freevo/src/video/plugins/dvdbackup.py
   branches/rel-1/freevo/src/video/plugins/reencode.py

Modified: branches/rel-1-7/freevo/freevo_config.py
==============================================================================
--- branches/rel-1-7/freevo/freevo_config.py    (original)
+++ branches/rel-1-7/freevo/freevo_config.py    Sun Jan 20 07:48:33 2008
@@ -1999,52 +1999,6 @@
 ENCODINGSERVER_IP   = 'localhost'
 ENCODINGSERVER_PORT = 6666
 
-# These paramaters are passed to mencoder, beware about changing them
-ENCODINGSERVER_CONTAINER_CAP_LIST = [ 'avi',  'mp4','mpeg' ] # add mkv back 
later
-ENCODINGSERVER_VIDEO_CODEC_LIST = [ 'MPEG 4 (lavc)','MPEG 2 (lavc)', 'XviD', 
'H.264' ]
-ENCODINGSERVER_AUDIO_CODEC_LIST = [ 'MPEG 1 Layer 3 (mp3)','MPEG 1 Layer 2 
(mp2)' ,'aac (iPod)', 'ac3', 'vorbis', 'copy' ]
-
-ENCODINGSERVER_VIDEO_FILTERS = {
-    'None' : ['None'],
-    'Deinterlacing' : ['None', 'Linear blend', 'Lavc deinterlacer'],
-    'Inverse Telecine' : ['None', 'On (stateless filter)'],
-    'Denoise' : ['None', 'Normal denoise', 'HQ denoise'],
-    'iPod' : ['iPod'],
-}
-
-ENCODINGSERVER_MENCODER_FILTERS = {
-    'Linear blend' : 'pp=lb',
-    'Lavc deinterlacer' : 'lavcdeint',
-    'On (stateless filter)' : 'ivtc=1',
-    'Normal denoise' : 'denoise3d',
-    'HQ denoise' : 'hqdn3d',
-    'iPod' : 'scale=320:240'
-}
-
-ENCODINGSERVER_MENCODER_VIDEO_MAPPING = {
-    'MPEG 4 (lavc)' : [ 'lavc', '-lavcopts', 
'vcodec=mpeg4:mbd=2:trell:v4mv:last_pred=2:dia=-1:vmax_b_frames=2:vb_strategy=1:cmp=3:subcmp=3:precmp=0:vqcomp=0.6:vbitrate=%s:threads=%s%s%s'],
-    'MPEG 2 (lavc)' : [ 'lavc', '-lavcopts', 
'vcodec=mpeg2video:vhq:vqmin=2:trell:vrc_buf_size=1835:vrc_maxrate=9800:keyint=18:vstrict=0:vbitrate=%s:threads=%s%s%s'],
-    'XviD'          : [ 'xvid', '-xvidencopts', 
'chroma_opt:vhq=4:bvhq=1:bitrate=%s:threads=%s%s%s'],
-    'H.264'         : [ 'x264', '-x264encopts', 
'subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:bitrate=%s:threads=%s%s%s']
-}
-
-ENCODINGSERVER_MENCODER_FILE_MAPPING = {
-    'mpeg' : [ 'mpeg', '-mpegopts', 'format=dvd:tsaf'],
-    'mp4' : [ 'lavf' , '-lavfopts', 'format=mp4', '-ffourcc', 'mp4v'    ],
-    'mkv' : [ 'lavf',  '-lavfopts', 'format=avi'],
-    'avi' : [ 'lavf' , '-lavfopts', 'format=avi']
-}
-
-ENCODINGSERVER_MENCODER_AUDIO_MAPPING = {
-    'MPEG 1 Layer 3 (mp3)' : ['lavc', '-lavcopts', 
'acodec=libmp3lame:abitrate=%s:aglobal=1'],
-    'aac (iPod)'           : ['lavc', '-lavcopts', 
'acodec=libfaac:abitrate=%s:aic=2:aglobal=1'],
-    'ac3'                  : ['lavc', '-lavcopts', 
'acodec=ac3:abitrate=%s:aglobal=1'],
-    'MPEG 1 Layer 2 (mp2)' : ['lavc', '-lavcopts', 
'acodec=mp2:abitrate=%s:aglobal=1'],
-    'vorbis'               : ['lavc', '-lavcopts', 
'acodec=vorbis:abitrate=%s:aglobal=1'],
-    'copy'                 : ['copy']
-}
-
-
 # ======================================================================
 # Freevo builtin commdetect server settings:
 # ======================================================================

Modified: branches/rel-1-7/freevo/src/encodingcore.py
==============================================================================
--- branches/rel-1-7/freevo/src/encodingcore.py (original)
+++ branches/rel-1-7/freevo/src/encodingcore.py Sun Jan 20 07:48:33 2008
@@ -49,14 +49,51 @@
 __license__ = 'GPL'
 
 
-ContainerCapList = config.ENCODINGSERVER_CONTAINER_CAP_LIST
-VideoCodecList   = config.ENCODINGSERVER_VIDEO_CODEC_LIST
-AudioCodecList   = config.ENCODINGSERVER_AUDIO_CODEC_LIST
-VideoFilters     = config.ENCODINGSERVER_VIDEO_FILTERS
-MencoderFilters  = config.ENCODINGSERVER_MENCODER_FILTERS
-MencoderFileMapping  = config.ENCODINGSERVER_MENCODER_FILE_MAPPING
-MencoderVideoMapping  = config.ENCODINGSERVER_MENCODER_VIDEO_MAPPING
-MencoderAudioMapping  = config.ENCODINGSERVER_MENCODER_AUDIO_MAPPING
+mappings = {
+    'lists' : {
+        'containers'  : [ 'avi', 'mp4', 'mpeg' ], # add mkv back later
+        'videocodecs' : [ 'MPEG 4 (lavc)','MPEG 2 (lavc)', 'XviD', 'H.264' ],
+        'audiocodecs' : [ 'MPEG 1 Layer 3 (mp3)', 'MPEG 1 Layer 2 (mp2)', 'AAC 
(iPod)', 'AC3', 'Vorbis', 'WMAv1',' WMAv2', 'copy' ]
+    },
+    'vcodec' : {
+        'MPEG 4 (lavc)' : [ 'lavc', '-lavcopts', 
'vcodec=mpeg4:mbd=2:trell:v4mv:last_pred=2:dia=-1:vmax_b_frames=2:vb_strategy=1:cmp=3:subcmp=3:precmp=0:vqcomp=0.6:vbitrate=%s:threads=%s%s%s'],
+        'MPEG 2 (lavc)' : [ 'lavc', '-lavcopts', 
'vcodec=mpeg2video:vhq:vqmin=2:trell:vrc_buf_size=1835:vrc_maxrate=9800:keyint=18:vstrict=0:vbitrate=%s:threads=%s%s%s'],
+        'XviD'          : [ 'xvid', '-xvidencopts', 
'chroma_opt:vhq=4:bvhq=1:bitrate=%s:threads=%s%s%s'],
+        'H.264'         : [ 'x264', '-x264encopts', 
'subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:bitrate=%s:threads=%s%s%s']
+    },
+    'container' : {
+        'mpeg' : [ 'mpeg', '-mpegopts', 'format=dvd:tsaf'],
+        'mp4' : [ 'lavf' , '-lavfopts', 'format=mp4', '-ffourcc', 'mp4v'    ],
+        'mkv' : [ 'lavf',  '-lavfopts', 'format=avi'],
+        'avi' : [ 'lavf' , '-lavfopts', 'format=avi']
+    },
+    'acodec' : {
+        'MPEG 1 Layer 3 (mp3)' : ['lavc', '-lavcopts', 
'acodec=libmp3lame:abitrate=%s:aglobal=1'],
+        'AAC (iPod)'           : ['lavc', '-lavcopts', 
'acodec=libfaac:abitrate=%s:aic=2:aglobal=1'],
+        'AC3'                  : ['lavc', '-lavcopts', 
'acodec=ac3:abitrate=%s:aglobal=1'],
+        'MPEG 1 Layer 2 (mp2)' : ['lavc', '-lavcopts', 
'acodec=mp2:abitrate=%s:aglobal=1'],
+        'Vorbis'               : ['lavc', '-lavcopts', 
'acodec=vorbis:abitrate=%s:aglobal=1'],
+        'WMAv1'                : ['lavc', '-lavcopts', 
'acodec=wmav1:abitrate=%s:aglobal=1'],
+        'WMAv2'                : ['lavc', '-lavcopts', 
'acodec=wmav2:abitrate=%s:aglobal=1'],
+        'copy'                 : ['copy']
+    },
+    'filter' : {
+        'Linear blend' : 'pp=lb',
+        'Lavc deinterlacer' : 'lavcdeint',
+        'On (stateless filter)' : 'ivtc=1',
+        'Normal denoise' : 'denoise3d',
+        'HQ denoise' : 'hqdn3d',
+        'iPod' : 'scale=320:240'
+    },
+    'filtertype' : {
+        'None' : ['None'],
+        'Deinterlacing' : ['None', 'Linear blend', 'Lavc deinterlacer'],
+        'Inverse Telecine' : ['None', 'On (stateless filter)'],
+        'Denoise' : ['None', 'Normal denoise', 'HQ denoise'],
+        'iPod' : ['iPod']
+    }, 
+}
+
 
 
 #from pytvgrab enum.py, see http://pytvgrab.sourceforge.net
@@ -74,6 +111,24 @@
 
 status = Enum(['notset', 'apass', 'vpass1', 'vpassfinal', 'postmerge'])
 
+class EncodingOptions:
+    def getContainerList(self):
+        """Return a list of possible containers"""
+        return mappings['lists']['containers']
+
+    def getVideoCodecList(self):
+        """Return a list of possible video codecs"""
+        return mappings['lists']['videocodecs']
+
+    def getAudioCodecList(self):
+        """Return a possible audio codec list"""
+        return mappings['lists']['audiocodecs']
+
+    def getVideoFiltersList(self):
+        """Return a list of possible video filters"""
+        return mappings['filtertype']
+
+
 class EncodingJob:
     """Class for creation & configuration of EncodingJobs. This generates the 
mencoder commands"""
 
@@ -83,7 +138,7 @@
             (source, output, friendlyname, idnr, chapter), 2)
         #currently only MEncoder can be used, but who knows what will happen 
in the future :)
         self._generateCL = self._GenerateCLMencoder
-
+        self.encodingopts = EncodingOptions()
         self.source = source
         self.output = output
         self.name = friendlyname
@@ -102,7 +157,7 @@
         self.crop = None
         self.cropres = None
 
-        self.acodec = AudioCodecList[0]
+        self.acodec = mappings['lists']['audiocodecs'][0]
         self.abrate = 128
         self.afilters = {} # Not used atm, might be used in the future
 
@@ -124,19 +179,26 @@
         self.resy = None
 
         self.threads = 1 # How many threads to use during encoding (multi core 
systems)
-
+        self.failed=False
         if self.source:
             try:
                 self.info = kaa.metadata.parse(self.source)
-                self._AnalyzeSource()
+                if self.info:
+                    self._AnalyzeSource()
+                else:
+                    print 'Failed to analyse "%s" kaa.metadata.parse()'  % 
self.source
+                    self.failed=True
+                    self.finishedanalyze = True
             except Exception, e:
                 print 'Failed to analyse "%s": %s' % (self.source, e)
+                self.failed=True
+                self.finishedanalyze = True
 
 
     def setContainer(self, container):
         """Set a container to hold the audio & video streams"""
         #safety checks
-        if container not in ContainerCapList:
+        if container not in self.encodingopts.getContainerList():
             return 'Unknown container format'
 
         self.container = container
@@ -148,21 +210,12 @@
         else:
             self.output = ('%s.%s' % (self.output, self.container))
 
-    def getContainerList(self):
-        """Return a list of possible containers"""
-        return ContainerCapList
-
-
-    def getVideoCodecList(self):
-        """Return a list of possible video codecs"""
-        return VideoCodecList
-
     def setVideoCodec(self, vcodec, tgtsize, multipass=False, vbitrate=0, 
altprofile=None):
         """Set video codec and target filesize (in MB) or bit rate (in 
kbits/sec)"""
         _debug_('setVideoCodec(self, vcodec=%s, tgtsize=%s, multipass=%s, 
vbitrate=%s)' % \
             (vcodec, tgtsize, multipass, vbitrate))
         #safety checks first
-        if vcodec not in self.getVideoCodecList():
+        if vcodec not in self.encodingopts.getVideoCodecList():
             return 'Unknown video codec'
 
         self.vcodec = vcodec
@@ -174,34 +227,21 @@
         self.vbitrate = vbitrate
         self.altprofile = altprofile
 
-    def getAudioCodecList(self):
-        """Return a possible audio codec list"""
-        return AudioCodecList
-
 
     def setAudioCodec(self, acodec, abrate=128):
         """Set audio codec & bitrate"""
         #safety first
-        if acodec not in self.getAudioCodecList():
+        if acodec not in self.encodingopts.getAudioCodecList():
             return 'Unknown audio codec'
 
         self.acodec = acodec
         self.abrate = abrate
 
-    def getVideoFiltersList(self):
-        """Return a list of possible video filters"""
-        if self.fps == 29.970:
-            return VideoFilters
-        else:
-            non_ivtcdict = VideoFilters.copy()
-            del non_ivtcdict['Inverse Telecine']
-            return non_ivtcdict
-
     def setVideoFilters(self, videofilters):
         """Set video filters"""
         for vfilter, option in videofilters:
-            if MencoderFilters.has_key(option):
-                self.vfilters += [ MencoderFilters[option] ]
+            if mappings['filter'].has_key(option):
+                self.vfilters += [ mappings['filter'][option]]
 
     def setVideoRes(self, videores):
         if videores == 'Optimal':
@@ -267,7 +307,7 @@
         else:
             sstep = 60
 
-        arguments = [ '-vf', 'cropdetect=30', '-nosound', '-vo', 'null', 
'-frames', '10', '-sstep', str(sstep)]
+        arguments = [ '-vf', 'cropdetect=30', '-nosound', '-vo', 'null', 
'-frames', '10','-fps=540', '-sstep', str(sstep)]
 
         if self.info.mime == 'video/dvd':
             arguments += [ '-dvd-device', self.source, 'dvd://%s' % 
self.chapter ]
@@ -321,7 +361,6 @@
         vfilter = ''
         vpass = ''
         yscaled = None
-        apro = ''
         #deinterlacer test vf += ['pp=lb']
         #set appropriate videopass, codec independant (lavc is vpass, xvid is 
pass)
         if passnr > 0:
@@ -393,30 +432,27 @@
             else:
                 aspect=':aspect=4/3'
         elif self.vcodec!='H.264':
-            aspect =  'autoaspect'
+            aspect =  ':autoaspect'
 
+        # set video encoder options
         if self.altprofile == None:
-            args = [
-                '-oac', MencoderAudioMapping[self.acodec][0],
-                '-ovc', MencoderVideoMapping[self.vcodec][0], 
MencoderVideoMapping[self.vcodec][1],
-                        MencoderVideoMapping[self.vcodec][2] % (self.vbrate, 
self.threads, vpass, aspect ),
-                '-o', output]
+            args = [ 
+                '-ovc', mappings['vcodec'][self.vcodec][0], 
mappings['vcodec'][self.vcodec][1],
+                        mappings['vcodec'][self.vcodec][2] % (self.vbrate, 
self.threads, vpass, aspect ) ]
         else:  # Allow encoder options from client
-            apro = '%s:vbitrate=%s:threads=%s%s%s' % (self.altprofile, 
self.vbrate, self.threads, vpass, aspect)
-            args = [
-                '-oac', MencoderAudioMapping[self.acodec][0],
-                '-ovc', MencoderVideoMapping[self.vcodec][0], 
MencoderVideoMapping[self.vcodec][1],
-                        apro,
-                '-o', output]
+            aprofile = '%s:vbitrate=%s:threads=%s%s%s' % (self.altprofile, 
self.vbrate, self.threads, vpass, aspect)
+            args = ['-ovc', 
mappings['vcodec'][self.vcodec][0],mappings['vcodec'][self.vcodec][1], aprofile 
]
+        
 
-        args +=  [ '-oac', MencoderAudioMapping[self.acodec][0] ]
+        # set audio encoder options
+        args += ['-oac' , mappings['acodec'][self.acodec][0] ] 
         if self.acodec != 'copy':
-            args +=  [ MencoderAudioMapping[self.acodec][1], 
(MencoderAudioMapping[self.acodec][2] % self.abrate)]
-
+            args += [ mappings['acodec'][self.acodec][1],
+                      mappings['acodec'][self.acodec][2] % self.abrate ]
+        args += [ '-o', output]
 
         # don't pass video filter in we have none
-
-        if len(vfilter) != '':
+        if len(vfilter) != 0:
             args += ['-vf', vfilter ]
 
         if passnr > 0:  # Remove when/if mencoder uses the same file name for 
all codecs
@@ -435,19 +471,13 @@
             else:
                 args += ['-ofps', '30000/1001'] # mencoder don't like 29.97
 
-        # Set output file type
-        if 'mp4' == self.container and 'iPodv' == self.vcodec:
-            args += ['-of', MencoderFileMapping[self.container][0], 
MencoderFileMapping[self.container][1],
-                           MencoderFileMapping[self.container][2], 
MencoderFileMapping[self.container][3],
-                           MencoderFileMapping[self.container][4] ]
-        else:
-            args += ['-of', MencoderFileMapping[self.container][0], 
MencoderFileMapping[self.container][1],
-                           MencoderFileMapping[self.container][2] ]
+        # Set output file container
+        args += ['-of'] + mappings['container'][self.container]
 
         #if we scale, use the bilinear algorithm
         if yscaled:
             args += ['-sws', '1']
-
+        
         return args
 
 
@@ -475,7 +505,7 @@
         foundrate = False
 
         try:
-            if not self.info.video[0].haskey('width') or not 
self.info.video[0].haskey('height'):
+            if not self.info.video[0].has_key('width') or not 
self.info.video[0].has_key('height'):
                 self.finishedanalyze = True
                 return
             crop = 
str(self.info.video[0].width)+':'+str(self.info.video[0].height)+':0:0'
@@ -519,8 +549,11 @@
                 if re_ana2.search(line):
                     self.ana = False
                 elif re_ana3.search(line):
-                    if not (self.info.video[0].haskey('width') / 
self.info.video[0].haskey('height')) > 1.3334:
-                        self.ana = False
+                    try:
+                        if not (self.info.video[0].has_key('width') / 
self.info.video[0].has_key('height')) > 1.3334:
+                            self.ana = False
+                    except:
+                        pass
                 else:
                     self.ana = True
 

Modified: branches/rel-1-7/freevo/src/helpers/encodingserver.py
==============================================================================
--- branches/rel-1-7/freevo/src/helpers/encodingserver.py       (original)
+++ branches/rel-1-7/freevo/src/helpers/encodingserver.py       Sun Jan 20 
07:48:33 2008
@@ -53,7 +53,7 @@
 import logging
 import config
 
-from encodingcore import EncodingJob, EncodingQueue
+from encodingcore import EncodingJob, EncodingQueue, EncodingOptions
 
 #some data
 __author__ = "den_RDC ([EMAIL PROTECTED])"
@@ -78,6 +78,7 @@
             xmlrpc.XMLRPC.__init__(self)
         self.debug = debug
         self.jobs = {}
+        self.encodingopts = EncodingOptions()
         self.queue = EncodingQueue()
         _debug_("EncodingServer started...", DINFO)
 
@@ -104,15 +105,18 @@
         #wait for the analyzing to end
         while not self.jobs[idnr].finishedanalyze:
             time.sleep(0.1)
+        if self.jobs[idnr].finishedanalyze == True and self.jobs[idnr].failed 
== True:
+                _debug_('Analysis failed')
+                return (False,10)
 
         _debug_("Initialized job %s (idnr : %s)" % (friendlyname, idnr), DINFO)
 
         return (True, idnr)
 
-    def xmlrpc_getContainerCAP(self, idnr):
+    def xmlrpc_getContainerCAP(self):
         """ Using Twisted get the container capabilities """
-        _debug_('xmlrpc_getContainerCAP(idnr=%r)' % (idnr), 2)
-        return (True, jam(self.jobs[idnr].getContainerList()))
+        _debug_('xmlrpc_getContainerCAP()' , 2)
+        return EncodingOptions.getContainerList( self.encodingopts)
 
     def xmlrpc_setContainer(self, idnr, container):
         """ Using Twisted set the container """
@@ -124,10 +128,10 @@
         else:
             return (False, "EncodingServer::setContainer: %s" % status)
 
-    def xmlrpc_getVideoCodecCAP(self, idnr):
+    def xmlrpc_getVideoCodecCAP(self):
         """ Using Twisted get the video capabilities """
-        _debug_('xmlrpc_getVideoCodecCAP(idnr=%r)' % (idnr), 2)
-        return (True, jam(self.jobs[idnr].getVideoCodecList()))
+        _debug_('xmlrpc_getVideoCodecCAP()', 2)
+        return EncodingOptions.getVideoCodecList(self.encodingopts)
 
     def xmlrpc_setVideoCodec(self, idnr, vcodec, tgtsize, multipass=False, 
vbitrate=0, altprofile=None):
         """ Using Twisted set the video codec """
@@ -144,10 +148,10 @@
         else:
             return (False, "EncodingServer::setVideoCodec: %s" % status)
 
-    def xmlrpc_getAudioCodecCAP(self, idnr):
+    def xmlrpc_getAudioCodecCAP(self):
         """ Using Twisted get the audio capabilities """
-        _debug_('xmlrpc_getAudioCodecCAP(idnr=%r)' % (idnr), 2)
-        return (True, jam(self.jobs[idnr].getAudioCodecList()))
+        _debug_('xmlrpc_getAudioCodecCAP()', 2)
+        return EncodingOptions.getAudioCodecList(self.encodingopts)
 
     def xmlrpc_setAudioCodec(self, idnr, acodec, abrate):
         """ Using Twisted set the audio codec """
@@ -194,10 +198,10 @@
             return (False, "EncodingServer::setNumThreads: %s" % status)
 
 
-    def xmlrpc_getVideoFiltersCAP(self, idnr):
+    def xmlrpc_getVideoFiltersCAP(self):
         """ Using Twisted get the video filter capabilities """
-        _debug_('xmlrpc_getVideoFiltersCAP(idnr=%r)' % (idnr), 2)
-        return (True, jam(self.jobs[idnr].getVideoFiltersList()))
+        _debug_('xmlrpc_getVideoFiltersCAP()', 2)
+        return EncodingOptions.getVideoFiltersList(self.encodingopts)
 
 
     def xmlrpc_setVideoFilters(self, idnr, filters):

Modified: branches/rel-1-7/freevo/src/video/encodingclient.py
==============================================================================
--- branches/rel-1-7/freevo/src/video/encodingclient.py (original)
+++ branches/rel-1-7/freevo/src/video/encodingclient.py Sun Jan 20 07:48:33 2008
@@ -121,7 +121,7 @@
     if not (source or output):
         return (False, "EncodingClient: no source and/or output")
 
-    try:
+    try: 
         (status, response) = server.initEncodeJob(source, output, 
friendlyname, title)
     except:
         print "Unexpected error:", sys.exc_info()[0]
@@ -130,22 +130,19 @@
 
     return (status, response)
 
-def getContainerCAP(idnr):
+def getContainerCAP():
     """Get a list of possible container formats
 
     This returns a list with plain strings, each identifiyng a container 
format, like
     Avi, MPEG or OGG. Currently only Avi is available. The strings are 
user-readable.
     """
 
-    if not idnr:
-        return (False, "EncodingClient: no idnr")
-
     try:
-        (status, response) = server.getContainerCAP(idnr)
+        response = server.getContainerCAP()
     except:
-        return (False, 'EncodingClient: connection error')
-
-    return returnFromJelly(status, response)
+        return (False ,'EncodingClient: connection error')
+    
+    return (True, response )
 
 def setContainer(idnr, container):
     """Set a container format
@@ -164,22 +161,19 @@
 
     return (status, response)
 
-def getVideoCodecCAP(idnr):
+def getVideoCodecCAP():
     """Get a list of possible video codecs (depending on the input and 
container format)
 
     This returns a list with plain strings, each identifiyng a video codec, 
like
     MPEG4(divx), Xvid etc. Currently only MPEG4 is available. The strings are 
user-readable.
     """
 
-    if not idnr:
-        return (False, "EncodingClient: no idnr")
-
     try:
-        (status, response) = server.getVideoCodecCAP(idnr)
+        response = server.getVideoCodecCAP()
     except:
-        return (False, 'EncodingClient: connection error')
+        return (False,'EncodingClient: connection error')
 
-    return returnFromJelly(status, response)
+    return (True,response)
 
 def setVideoCodec(idnr, vcodec, tgtsize, multipass=False, vbitrate=0, 
altprofile=None):
     """Set a video codec
@@ -188,8 +182,8 @@
         returned by getVideoCodecCAP.
     @param tgtsize: is the target size of the encoded file, in megabytes (this 
includes
         audio data and container format overhead)
-    @param multipass: is a boolean. Set this to True if you want multipass 
encoding (1 audio
-        pass, 2 video passes). The default is no multipass (1 audio, 1 video)
+    @param multipass: is a boolean. Set this to True if you want multipass 
encoding 
+        ( 1 pass, 2 video passes). The default is no multipass ( 1 video)
     @param vbitrate: is the video bitrate, if it is not 0 then this value is 
used instead
         of using the tgtsize.
     """
@@ -204,22 +198,19 @@
 
     return (status, response)
 
-def getAudioCodecCAP(idnr):
+def getAudioCodecCAP():
     """Get a list of possible audio codecs (depending on the input and 
container format)
 
     This returns a list with plain strings, each identifiyng a audio codec, 
like
     MP3, Ogg, etc. Currently only MP3 is available. The strings are 
user-readable.
     """
 
-    if not idnr:
-        return (False, "EncodingClient: no idnr")
-
     try:
-        (status, response) = server.getAudioCodecCAP(idnr)
+        response = server.getAudioCodecCAP()
     except:
         return (False, 'EncodingClient: connection error')
 
-    return returnFromJelly(status, response)
+    return (True, response )
 
 def setAudioCodec(idnr, acodec, abrate):
     """Set a audio codec
@@ -276,7 +267,7 @@
 
     return (status, response)
 
-def getVideoFiltersCAP(idnr):
+def getVideoFiltersCAP():
     """Get a dict of possible video filters & processing operations
 
     This returns a dictionary, with the filter (human-readable string) as 
keyword, and
@@ -284,15 +275,12 @@
     The first option in the list is the default.
     """
 
-    if not idnr:
-        return (False, "EncodingClient: no idnr")
-
     try:
-        (status, response) = server.getVideoFiltersCAP(idnr)
+        response = server.getVideoFiltersCAP()
     except:
         return (False, 'EncodingClient: connection error')
 
-    return returnFromJelly(status, response)
+    return (True ,response)
 
 def setVideoFilters(idnr, filters):
     """Set a number of possible video filters & processing operations

Modified: branches/rel-1-7/freevo/src/video/plugins/dvdbackup.py
==============================================================================
--- branches/rel-1-7/freevo/src/video/plugins/dvdbackup.py      (original)
+++ branches/rel-1-7/freevo/src/video/plugins/dvdbackup.py      Sun Jan 20 
07:48:33 2008
@@ -124,7 +124,7 @@
         idnr = resp
 
         #ask for possible containers and set the first one (should be avi), we 
will get a list
-        (status, resp) = getContainerCAP(idnr)
+        (status, resp) = getContainerCAP()
 
         if not status:
             self.error(resp)
@@ -139,7 +139,7 @@
             return
 
         #ask for possible videocodec and set the first one (should be mpeg4), 
we will get a list
-        (status, resp) = getVideoCodecCAP(idnr)
+        (status, resp) = getVideoCodecCAP()
 
         if not status:
             self.error(resp)
@@ -156,7 +156,7 @@
         #ask for possible audiocodec and set the first one (should be mp3), we 
will get a list
         #Audiocodec call isn't necessary atm, it defaults to 128 kbit mp3, but 
this might change in the future
         #so we play safe
-        (status, resp) = getAudioCodecCAP(idnr)
+        (status, resp) = getAudioCodecCAP()
 
         if not status:
             self.error(resp)

Modified: branches/rel-1-7/freevo/src/video/plugins/reencode.py
==============================================================================
--- branches/rel-1-7/freevo/src/video/plugins/reencode.py       (original)
+++ branches/rel-1-7/freevo/src/video/plugins/reencode.py       Sun Jan 20 
07:48:33 2008
@@ -35,7 +35,6 @@
 import os
 import config
 from video.encodingclient import *
-from encodingcore import ContainerCapList, VideoCodecList, AudioCodecList, 
VideoFilters
 from gui.AlertBox import AlertBox
 from gui.PopupBox import PopupBox
 
@@ -177,7 +176,7 @@
     def mod_container(self, arg=None, menuw=None):
         _debug_('mod_container(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
-        for container in ContainerCapList:
+        for container in getContainerCAP()[1]:
             items.append(menu.MenuItem(container, action=self.alter_prop, 
arg=('container', container)))
         container_menu = menu.Menu(_('Modify Container'), items, item_types = 
'video encoding menu')
         container_menu.infoitem = self
@@ -197,7 +196,7 @@
     def mod_videocodec(self, arg=None, menuw=None):
         _debug_('mod_videocodec(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
-        for videocodec in VideoCodecList:
+        for videocodec in getVideoCodecCAP()[1]:
             items.append(menu.MenuItem(videocodec, action=self.alter_prop, 
arg=('videocodec', videocodec)))
         videocodec_menu = menu.Menu(_('Modify Video Codec'), items, item_types 
= 'video encoding menu')
         videocodec_menu.infoitem = self
@@ -217,7 +216,7 @@
     def mod_audiocodec(self, arg=None, menuw=None):
         _debug_('mod_audiocodec(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
-        for audiocodec in AudioCodecList:
+        for audiocodec in getAudioCodecCAP()[1]:
             items.append(menu.MenuItem(audiocodec, action=self.alter_prop, 
arg=('audiocodec', audiocodec)))
         audiocodec_menu = menu.Menu(_('Modify Video Codec'), items, item_types 
= 'video encoding menu')
         audiocodec_menu.infoitem = self
@@ -257,7 +256,7 @@
     def mod_videofilter(self, arg=None, menuw=None):
         _debug_('mod_videofilter(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
-        for videofilter in VideoFilters:
+        for videofilter in getVideoFiltersCAP()[1]:
             items.append(menu.MenuItem(videofilter, action=self.alter_prop, 
arg=('videofilter', videofilter)))
         videofilter_menu = menu.Menu(_('Modify Video Filter'), items, 
item_types = 'video encoding menu')
         videofilter_menu.infoitem = self
@@ -293,7 +292,7 @@
             self.profile['videocodec'] = 'MPEG 4 (lavc)'
             self.profile['altprofile'] = 
'vcodec=mpeg4:mbd=2:cmp=2:subcmp=2:trell=yes:v4mv=yes:vglobal=1'
             self.profile['videobitrate'] = 1200
-            self.profile['audiocodec'] = 'aac (iPod)'
+            self.profile['audiocodec'] = 'AAC (iPod)'
             self.profile['audiobitrate'] = 192
             self.profile['numpasses'] = 2
             self.profile['videofilter'] = 'ipod'
@@ -303,7 +302,7 @@
             self.profile['videocodec'] = 'MPEG 2 (lavc)'
             self.profile['altprofile'] = None
             self.profile['videobitrate'] = 5200
-            self.profile['audiocodec'] = 'ac3'
+            self.profile['audiocodec'] = 'AC3'
             self.profile['audiobitrate'] = 224
             self.profile['numpasses'] = 1
             self.profile['videofilter'] = 'None'

Modified: branches/rel-1/freevo/freevo_config.py
==============================================================================
--- branches/rel-1/freevo/freevo_config.py      (original)
+++ branches/rel-1/freevo/freevo_config.py      Sun Jan 20 07:48:33 2008
@@ -2004,52 +2004,6 @@
 ENCODINGSERVER_IP   = 'localhost'
 ENCODINGSERVER_PORT = 6666
 
-# These paramaters are passed to mencoder, beware about changing them
-ENCODINGSERVER_CONTAINER_CAP_LIST = [ 'avi',  'mp4','mpeg' ] # add mkv back 
later
-ENCODINGSERVER_VIDEO_CODEC_LIST = [ 'MPEG 4 (lavc)','MPEG 2 (lavc)', 'XviD', 
'H.264' ]
-ENCODINGSERVER_AUDIO_CODEC_LIST = [ 'MPEG 1 Layer 3 (mp3)','MPEG 1 Layer 2 
(mp2)' ,'aac (iPod)', 'ac3', 'vorbis', 'copy' ]
-
-ENCODINGSERVER_VIDEO_FILTERS = {
-    'None' : ['None'],
-    'Deinterlacing' : ['None', 'Linear blend', 'Lavc deinterlacer'],
-    'Inverse Telecine' : ['None', 'On (stateless filter)'],
-    'Denoise' : ['None', 'Normal denoise', 'HQ denoise'],
-    'iPod' : ['iPod'],
-}
-
-ENCODINGSERVER_MENCODER_FILTERS = {
-    'Linear blend' : 'pp=lb',
-    'Lavc deinterlacer' : 'lavcdeint',
-    'On (stateless filter)' : 'ivtc=1',
-    'Normal denoise' : 'denoise3d',
-    'HQ denoise' : 'hqdn3d',
-    'iPod' : 'scale=320:240'
-}
-
-ENCODINGSERVER_MENCODER_VIDEO_MAPPING = {
-    'MPEG 4 (lavc)' : [ 'lavc', '-lavcopts', 
'vcodec=mpeg4:mbd=2:trell:v4mv:last_pred=2:dia=-1:vmax_b_frames=2:vb_strategy=1:cmp=3:subcmp=3:precmp=0:vqcomp=0.6:vbitrate=%s:threads=%s%s%s'],
-    'MPEG 2 (lavc)' : [ 'lavc', '-lavcopts', 
'vcodec=mpeg2video:vhq:vqmin=2:trell:vrc_buf_size=1835:vrc_maxrate=9800:keyint=18:vstrict=0:vbitrate=%s:threads=%s%s%s'],
-    'XviD'          : [ 'xvid', '-xvidencopts', 
'chroma_opt:vhq=4:bvhq=1:bitrate=%s:threads=%s%s%s'],
-    'H.264'         : [ 'x264', '-x264encopts', 
'subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:bitrate=%s:threads=%s%s%s']
-}
-
-ENCODINGSERVER_MENCODER_FILE_MAPPING = {
-    'mpeg' : [ 'mpeg', '-mpegopts', 'format=dvd:tsaf'],
-    'mp4' : [ 'lavf' , '-lavfopts', 'format=mp4', '-ffourcc', 'mp4v'    ],
-    'mkv' : [ 'lavf',  '-lavfopts', 'format=avi'],
-    'avi' : [ 'lavf' , '-lavfopts', 'format=avi']
-}
-
-ENCODINGSERVER_MENCODER_AUDIO_MAPPING = {
-    'MPEG 1 Layer 3 (mp3)' : ['lavc', '-lavcopts', 
'acodec=libmp3lame:abitrate=%s:aglobal=1'],
-    'aac (iPod)'           : ['lavc', '-lavcopts', 
'acodec=libfaac:abitrate=%s:aic=2:aglobal=1'],
-    'ac3'                  : ['lavc', '-lavcopts', 
'acodec=ac3:abitrate=%s:aglobal=1'],
-    'MPEG 1 Layer 2 (mp2)' : ['lavc', '-lavcopts', 
'acodec=mp2:abitrate=%s:aglobal=1'],
-    'vorbis'               : ['lavc', '-lavcopts', 
'acodec=vorbis:abitrate=%s:aglobal=1'],
-    'copy'                 : ['copy']
-}
-
-
 # ======================================================================
 # Freevo builtin commdetect server settings:
 # ======================================================================

Modified: branches/rel-1/freevo/src/encodingcore.py
==============================================================================
--- branches/rel-1/freevo/src/encodingcore.py   (original)
+++ branches/rel-1/freevo/src/encodingcore.py   Sun Jan 20 07:48:33 2008
@@ -49,14 +49,51 @@
 __license__ = 'GPL'
 
 
-ContainerCapList = config.ENCODINGSERVER_CONTAINER_CAP_LIST
-VideoCodecList   = config.ENCODINGSERVER_VIDEO_CODEC_LIST
-AudioCodecList   = config.ENCODINGSERVER_AUDIO_CODEC_LIST
-VideoFilters     = config.ENCODINGSERVER_VIDEO_FILTERS
-MencoderFilters  = config.ENCODINGSERVER_MENCODER_FILTERS
-MencoderFileMapping  = config.ENCODINGSERVER_MENCODER_FILE_MAPPING
-MencoderVideoMapping  = config.ENCODINGSERVER_MENCODER_VIDEO_MAPPING
-MencoderAudioMapping  = config.ENCODINGSERVER_MENCODER_AUDIO_MAPPING
+mappings = {
+    'lists' : {
+        'containers'  : [ 'avi', 'mp4', 'mpeg' ], # add mkv back later
+        'videocodecs' : [ 'MPEG 4 (lavc)','MPEG 2 (lavc)', 'XviD', 'H.264' ],
+        'audiocodecs' : [ 'MPEG 1 Layer 3 (mp3)', 'MPEG 1 Layer 2 (mp2)', 'AAC 
(iPod)', 'AC3', 'Vorbis', 'WMAv1',' WMAv2', 'copy' ]
+    },
+    'vcodec' : {
+        'MPEG 4 (lavc)' : [ 'lavc', '-lavcopts', 
'vcodec=mpeg4:mbd=2:trell:v4mv:last_pred=2:dia=-1:vmax_b_frames=2:vb_strategy=1:cmp=3:subcmp=3:precmp=0:vqcomp=0.6:vbitrate=%s:threads=%s%s%s'],
+        'MPEG 2 (lavc)' : [ 'lavc', '-lavcopts', 
'vcodec=mpeg2video:vhq:vqmin=2:trell:vrc_buf_size=1835:vrc_maxrate=9800:keyint=18:vstrict=0:vbitrate=%s:threads=%s%s%s'],
+        'XviD'          : [ 'xvid', '-xvidencopts', 
'chroma_opt:vhq=4:bvhq=1:bitrate=%s:threads=%s%s%s'],
+        'H.264'         : [ 'x264', '-x264encopts', 
'subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:bitrate=%s:threads=%s%s%s']
+    },
+    'container' : {
+        'mpeg' : [ 'mpeg', '-mpegopts', 'format=dvd:tsaf'],
+        'mp4' : [ 'lavf' , '-lavfopts', 'format=mp4', '-ffourcc', 'mp4v'    ],
+        'mkv' : [ 'lavf',  '-lavfopts', 'format=avi'],
+        'avi' : [ 'lavf' , '-lavfopts', 'format=avi']
+    },
+    'acodec' : {
+        'MPEG 1 Layer 3 (mp3)' : ['lavc', '-lavcopts', 
'acodec=libmp3lame:abitrate=%s:aglobal=1'],
+        'AAC (iPod)'           : ['lavc', '-lavcopts', 
'acodec=libfaac:abitrate=%s:aic=2:aglobal=1'],
+        'AC3'                  : ['lavc', '-lavcopts', 
'acodec=ac3:abitrate=%s:aglobal=1'],
+        'MPEG 1 Layer 2 (mp2)' : ['lavc', '-lavcopts', 
'acodec=mp2:abitrate=%s:aglobal=1'],
+        'Vorbis'               : ['lavc', '-lavcopts', 
'acodec=vorbis:abitrate=%s:aglobal=1'],
+        'WMAv1'                : ['lavc', '-lavcopts', 
'acodec=wmav1:abitrate=%s:aglobal=1'],
+        'WMAv2'                : ['lavc', '-lavcopts', 
'acodec=wmav2:abitrate=%s:aglobal=1'],
+        'copy'                 : ['copy']
+    },
+    'filter' : {
+        'Linear blend' : 'pp=lb',
+        'Lavc deinterlacer' : 'lavcdeint',
+        'On (stateless filter)' : 'ivtc=1',
+        'Normal denoise' : 'denoise3d',
+        'HQ denoise' : 'hqdn3d',
+        'iPod' : 'scale=320:240'
+    },
+    'filtertype' : {
+        'None' : ['None'],
+        'Deinterlacing' : ['None', 'Linear blend', 'Lavc deinterlacer'],
+        'Inverse Telecine' : ['None', 'On (stateless filter)'],
+        'Denoise' : ['None', 'Normal denoise', 'HQ denoise'],
+        'iPod' : ['iPod']
+    }, 
+}
+
 
 
 #from pytvgrab enum.py, see http://pytvgrab.sourceforge.net
@@ -74,6 +111,24 @@
 
 status = Enum(['notset', 'apass', 'vpass1', 'vpassfinal', 'postmerge'])
 
+class EncodingOptions:
+    def getContainerList(self):
+        """Return a list of possible containers"""
+        return mappings['lists']['containers']
+
+    def getVideoCodecList(self):
+        """Return a list of possible video codecs"""
+        return mappings['lists']['videocodecs']
+
+    def getAudioCodecList(self):
+        """Return a possible audio codec list"""
+        return mappings['lists']['audiocodecs']
+
+    def getVideoFiltersList(self):
+        """Return a list of possible video filters"""
+        return mappings['filtertype']
+
+
 class EncodingJob:
     """Class for creation & configuration of EncodingJobs. This generates the 
mencoder commands"""
 
@@ -83,7 +138,7 @@
             (source, output, friendlyname, idnr, chapter), 2)
         #currently only MEncoder can be used, but who knows what will happen 
in the future :)
         self._generateCL = self._GenerateCLMencoder
-
+        self.encodingopts = EncodingOptions()
         self.source = source
         self.output = output
         self.name = friendlyname
@@ -102,7 +157,7 @@
         self.crop = None
         self.cropres = None
 
-        self.acodec = AudioCodecList[0]
+        self.acodec = mappings['lists']['audiocodecs'][0]
         self.abrate = 128
         self.afilters = {} # Not used atm, might be used in the future
 
@@ -124,19 +179,26 @@
         self.resy = None
 
         self.threads = 1 # How many threads to use during encoding (multi core 
systems)
-
+        self.failed=False
         if self.source:
             try:
                 self.info = kaa.metadata.parse(self.source)
-                self._AnalyzeSource()
+                if self.info:
+                    self._AnalyzeSource()
+                else:
+                    print 'Failed to analyse "%s" kaa.metadata.parse()'  % 
self.source
+                    self.failed=True
+                    self.finishedanalyze = True
             except Exception, e:
                 print 'Failed to analyse "%s": %s' % (self.source, e)
+                self.failed=True
+                self.finishedanalyze = True
 
 
     def setContainer(self, container):
         """Set a container to hold the audio & video streams"""
         #safety checks
-        if container not in ContainerCapList:
+        if container not in self.encodingopts.getContainerList():
             return 'Unknown container format'
 
         self.container = container
@@ -148,21 +210,12 @@
         else:
             self.output = ('%s.%s' % (self.output, self.container))
 
-    def getContainerList(self):
-        """Return a list of possible containers"""
-        return ContainerCapList
-
-
-    def getVideoCodecList(self):
-        """Return a list of possible video codecs"""
-        return VideoCodecList
-
     def setVideoCodec(self, vcodec, tgtsize, multipass=False, vbitrate=0, 
altprofile=None):
         """Set video codec and target filesize (in MB) or bit rate (in 
kbits/sec)"""
         _debug_('setVideoCodec(self, vcodec=%s, tgtsize=%s, multipass=%s, 
vbitrate=%s)' % \
             (vcodec, tgtsize, multipass, vbitrate))
         #safety checks first
-        if vcodec not in self.getVideoCodecList():
+        if vcodec not in self.encodingopts.getVideoCodecList():
             return 'Unknown video codec'
 
         self.vcodec = vcodec
@@ -174,34 +227,21 @@
         self.vbitrate = vbitrate
         self.altprofile = altprofile
 
-    def getAudioCodecList(self):
-        """Return a possible audio codec list"""
-        return AudioCodecList
-
 
     def setAudioCodec(self, acodec, abrate=128):
         """Set audio codec & bitrate"""
         #safety first
-        if acodec not in self.getAudioCodecList():
+        if acodec not in self.encodingopts.getAudioCodecList():
             return 'Unknown audio codec'
 
         self.acodec = acodec
         self.abrate = abrate
 
-    def getVideoFiltersList(self):
-        """Return a list of possible video filters"""
-        if self.fps == 29.970:
-            return VideoFilters
-        else:
-            non_ivtcdict = VideoFilters.copy()
-            del non_ivtcdict['Inverse Telecine']
-            return non_ivtcdict
-
     def setVideoFilters(self, videofilters):
         """Set video filters"""
         for vfilter, option in videofilters:
-            if MencoderFilters.has_key(option):
-                self.vfilters += [ MencoderFilters[option] ]
+            if mappings['filter'].has_key(option):
+                self.vfilters += [ mappings['filter'][option]]
 
     def setVideoRes(self, videores):
         if videores == 'Optimal':
@@ -267,7 +307,7 @@
         else:
             sstep = 60
 
-        arguments = [ '-vf', 'cropdetect=30', '-nosound', '-vo', 'null', 
'-frames', '10', '-sstep', str(sstep)]
+        arguments = [ '-vf', 'cropdetect=30', '-nosound', '-vo', 'null', 
'-frames', '10','-fps=540', '-sstep', str(sstep)]
 
         if self.info.mime == 'video/dvd':
             arguments += [ '-dvd-device', self.source, 'dvd://%s' % 
self.chapter ]
@@ -321,7 +361,6 @@
         vfilter = ''
         vpass = ''
         yscaled = None
-        apro = ''
         #deinterlacer test vf += ['pp=lb']
         #set appropriate videopass, codec independant (lavc is vpass, xvid is 
pass)
         if passnr > 0:
@@ -393,30 +432,27 @@
             else:
                 aspect=':aspect=4/3'
         elif self.vcodec!='H.264':
-            aspect =  'autoaspect'
+            aspect =  ':autoaspect'
 
+        # set video encoder options
         if self.altprofile == None:
-            args = [
-                '-oac', MencoderAudioMapping[self.acodec][0],
-                '-ovc', MencoderVideoMapping[self.vcodec][0], 
MencoderVideoMapping[self.vcodec][1],
-                        MencoderVideoMapping[self.vcodec][2] % (self.vbrate, 
self.threads, vpass, aspect ),
-                '-o', output]
+            args = [ 
+                '-ovc', mappings['vcodec'][self.vcodec][0], 
mappings['vcodec'][self.vcodec][1],
+                        mappings['vcodec'][self.vcodec][2] % (self.vbrate, 
self.threads, vpass, aspect ) ]
         else:  # Allow encoder options from client
-            apro = '%s:vbitrate=%s:threads=%s%s%s' % (self.altprofile, 
self.vbrate, self.threads, vpass, aspect)
-            args = [
-                '-oac', MencoderAudioMapping[self.acodec][0],
-                '-ovc', MencoderVideoMapping[self.vcodec][0], 
MencoderVideoMapping[self.vcodec][1],
-                        apro,
-                '-o', output]
+            aprofile = '%s:vbitrate=%s:threads=%s%s%s' % (self.altprofile, 
self.vbrate, self.threads, vpass, aspect)
+            args = ['-ovc', 
mappings['vcodec'][self.vcodec][0],mappings['vcodec'][self.vcodec][1], aprofile 
]
+        
 
-        args +=  [ '-oac', MencoderAudioMapping[self.acodec][0] ]
+        # set audio encoder options
+        args += ['-oac' , mappings['acodec'][self.acodec][0] ] 
         if self.acodec != 'copy':
-            args +=  [ MencoderAudioMapping[self.acodec][1], 
(MencoderAudioMapping[self.acodec][2] % self.abrate)]
-
+            args += [ mappings['acodec'][self.acodec][1],
+                      mappings['acodec'][self.acodec][2] % self.abrate ]
+        args += [ '-o', output]
 
         # don't pass video filter in we have none
-
-        if len(vfilter) != '':
+        if len(vfilter) != 0:
             args += ['-vf', vfilter ]
 
         if passnr > 0:  # Remove when/if mencoder uses the same file name for 
all codecs
@@ -435,19 +471,13 @@
             else:
                 args += ['-ofps', '30000/1001'] # mencoder don't like 29.97
 
-        # Set output file type
-        if 'mp4' == self.container and 'iPodv' == self.vcodec:
-            args += ['-of', MencoderFileMapping[self.container][0], 
MencoderFileMapping[self.container][1],
-                           MencoderFileMapping[self.container][2], 
MencoderFileMapping[self.container][3],
-                           MencoderFileMapping[self.container][4] ]
-        else:
-            args += ['-of', MencoderFileMapping[self.container][0], 
MencoderFileMapping[self.container][1],
-                           MencoderFileMapping[self.container][2] ]
+        # Set output file container
+        args += ['-of'] + mappings['container'][self.container]
 
         #if we scale, use the bilinear algorithm
         if yscaled:
             args += ['-sws', '1']
-
+        
         return args
 
 
@@ -475,7 +505,7 @@
         foundrate = False
 
         try:
-            if not self.info.video[0].haskey('width') or not 
self.info.video[0].haskey('height'):
+            if not self.info.video[0].has_key('width') or not 
self.info.video[0].has_key('height'):
                 self.finishedanalyze = True
                 return
             crop = 
str(self.info.video[0].width)+':'+str(self.info.video[0].height)+':0:0'
@@ -519,8 +549,11 @@
                 if re_ana2.search(line):
                     self.ana = False
                 elif re_ana3.search(line):
-                    if not (self.info.video[0].haskey('width') / 
self.info.video[0].haskey('height')) > 1.3334:
-                        self.ana = False
+                    try:
+                        if not (self.info.video[0].has_key('width') / 
self.info.video[0].has_key('height')) > 1.3334:
+                            self.ana = False
+                    except:
+                        pass
                 else:
                     self.ana = True
 

Modified: branches/rel-1/freevo/src/helpers/encodingserver.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/encodingserver.py (original)
+++ branches/rel-1/freevo/src/helpers/encodingserver.py Sun Jan 20 07:48:33 2008
@@ -53,7 +53,7 @@
 import logging
 import config
 
-from encodingcore import EncodingJob, EncodingQueue
+from encodingcore import EncodingJob, EncodingQueue, EncodingOptions
 
 #some data
 __author__ = "den_RDC ([EMAIL PROTECTED])"
@@ -78,6 +78,7 @@
             xmlrpc.XMLRPC.__init__(self)
         self.debug = debug
         self.jobs = {}
+        self.encodingopts = EncodingOptions()
         self.queue = EncodingQueue()
         _debug_("EncodingServer started...", DINFO)
 
@@ -104,15 +105,18 @@
         #wait for the analyzing to end
         while not self.jobs[idnr].finishedanalyze:
             time.sleep(0.1)
+        if self.jobs[idnr].finishedanalyze == True and self.jobs[idnr].failed 
== True:
+                _debug_('Analysis failed')
+                return (False,10)
 
         _debug_("Initialized job %s (idnr : %s)" % (friendlyname, idnr), DINFO)
 
         return (True, idnr)
 
-    def xmlrpc_getContainerCAP(self, idnr):
+    def xmlrpc_getContainerCAP(self):
         """ Using Twisted get the container capabilities """
-        _debug_('xmlrpc_getContainerCAP(idnr=%r)' % (idnr), 2)
-        return (True, jam(self.jobs[idnr].getContainerList()))
+        _debug_('xmlrpc_getContainerCAP()' , 2)
+        return EncodingOptions.getContainerList( self.encodingopts)
 
     def xmlrpc_setContainer(self, idnr, container):
         """ Using Twisted set the container """
@@ -124,10 +128,10 @@
         else:
             return (False, "EncodingServer::setContainer: %s" % status)
 
-    def xmlrpc_getVideoCodecCAP(self, idnr):
+    def xmlrpc_getVideoCodecCAP(self):
         """ Using Twisted get the video capabilities """
-        _debug_('xmlrpc_getVideoCodecCAP(idnr=%r)' % (idnr), 2)
-        return (True, jam(self.jobs[idnr].getVideoCodecList()))
+        _debug_('xmlrpc_getVideoCodecCAP()', 2)
+        return EncodingOptions.getVideoCodecList(self.encodingopts)
 
     def xmlrpc_setVideoCodec(self, idnr, vcodec, tgtsize, multipass=False, 
vbitrate=0, altprofile=None):
         """ Using Twisted set the video codec """
@@ -144,10 +148,10 @@
         else:
             return (False, "EncodingServer::setVideoCodec: %s" % status)
 
-    def xmlrpc_getAudioCodecCAP(self, idnr):
+    def xmlrpc_getAudioCodecCAP(self):
         """ Using Twisted get the audio capabilities """
-        _debug_('xmlrpc_getAudioCodecCAP(idnr=%r)' % (idnr), 2)
-        return (True, jam(self.jobs[idnr].getAudioCodecList()))
+        _debug_('xmlrpc_getAudioCodecCAP()', 2)
+        return EncodingOptions.getAudioCodecList(self.encodingopts)
 
     def xmlrpc_setAudioCodec(self, idnr, acodec, abrate):
         """ Using Twisted set the audio codec """
@@ -194,10 +198,10 @@
             return (False, "EncodingServer::setNumThreads: %s" % status)
 
 
-    def xmlrpc_getVideoFiltersCAP(self, idnr):
+    def xmlrpc_getVideoFiltersCAP(self):
         """ Using Twisted get the video filter capabilities """
-        _debug_('xmlrpc_getVideoFiltersCAP(idnr=%r)' % (idnr), 2)
-        return (True, jam(self.jobs[idnr].getVideoFiltersList()))
+        _debug_('xmlrpc_getVideoFiltersCAP()', 2)
+        return EncodingOptions.getVideoFiltersList(self.encodingopts)
 
 
     def xmlrpc_setVideoFilters(self, idnr, filters):

Modified: branches/rel-1/freevo/src/video/encodingclient.py
==============================================================================
--- branches/rel-1/freevo/src/video/encodingclient.py   (original)
+++ branches/rel-1/freevo/src/video/encodingclient.py   Sun Jan 20 07:48:33 2008
@@ -121,7 +121,7 @@
     if not (source or output):
         return (False, "EncodingClient: no source and/or output")
 
-    try:
+    try: 
         (status, response) = server.initEncodeJob(source, output, 
friendlyname, title)
     except:
         print "Unexpected error:", sys.exc_info()[0]
@@ -130,22 +130,19 @@
 
     return (status, response)
 
-def getContainerCAP(idnr):
+def getContainerCAP():
     """Get a list of possible container formats
 
     This returns a list with plain strings, each identifiyng a container 
format, like
     Avi, MPEG or OGG. Currently only Avi is available. The strings are 
user-readable.
     """
 
-    if not idnr:
-        return (False, "EncodingClient: no idnr")
-
     try:
-        (status, response) = server.getContainerCAP(idnr)
+        response = server.getContainerCAP()
     except:
-        return (False, 'EncodingClient: connection error')
-
-    return returnFromJelly(status, response)
+        return (False ,'EncodingClient: connection error')
+    
+    return (True, response )
 
 def setContainer(idnr, container):
     """Set a container format
@@ -164,22 +161,19 @@
 
     return (status, response)
 
-def getVideoCodecCAP(idnr):
+def getVideoCodecCAP():
     """Get a list of possible video codecs (depending on the input and 
container format)
 
     This returns a list with plain strings, each identifiyng a video codec, 
like
     MPEG4(divx), Xvid etc. Currently only MPEG4 is available. The strings are 
user-readable.
     """
 
-    if not idnr:
-        return (False, "EncodingClient: no idnr")
-
     try:
-        (status, response) = server.getVideoCodecCAP(idnr)
+        response = server.getVideoCodecCAP()
     except:
-        return (False, 'EncodingClient: connection error')
+        return (False,'EncodingClient: connection error')
 
-    return returnFromJelly(status, response)
+    return (True,response)
 
 def setVideoCodec(idnr, vcodec, tgtsize, multipass=False, vbitrate=0, 
altprofile=None):
     """Set a video codec
@@ -188,8 +182,8 @@
         returned by getVideoCodecCAP.
     @param tgtsize: is the target size of the encoded file, in megabytes (this 
includes
         audio data and container format overhead)
-    @param multipass: is a boolean. Set this to True if you want multipass 
encoding (1 audio
-        pass, 2 video passes). The default is no multipass (1 audio, 1 video)
+    @param multipass: is a boolean. Set this to True if you want multipass 
encoding 
+        ( 1 pass, 2 video passes). The default is no multipass ( 1 video)
     @param vbitrate: is the video bitrate, if it is not 0 then this value is 
used instead
         of using the tgtsize.
     """
@@ -204,22 +198,19 @@
 
     return (status, response)
 
-def getAudioCodecCAP(idnr):
+def getAudioCodecCAP():
     """Get a list of possible audio codecs (depending on the input and 
container format)
 
     This returns a list with plain strings, each identifiyng a audio codec, 
like
     MP3, Ogg, etc. Currently only MP3 is available. The strings are 
user-readable.
     """
 
-    if not idnr:
-        return (False, "EncodingClient: no idnr")
-
     try:
-        (status, response) = server.getAudioCodecCAP(idnr)
+        response = server.getAudioCodecCAP()
     except:
         return (False, 'EncodingClient: connection error')
 
-    return returnFromJelly(status, response)
+    return (True, response )
 
 def setAudioCodec(idnr, acodec, abrate):
     """Set a audio codec
@@ -276,7 +267,7 @@
 
     return (status, response)
 
-def getVideoFiltersCAP(idnr):
+def getVideoFiltersCAP():
     """Get a dict of possible video filters & processing operations
 
     This returns a dictionary, with the filter (human-readable string) as 
keyword, and
@@ -284,15 +275,12 @@
     The first option in the list is the default.
     """
 
-    if not idnr:
-        return (False, "EncodingClient: no idnr")
-
     try:
-        (status, response) = server.getVideoFiltersCAP(idnr)
+        response = server.getVideoFiltersCAP()
     except:
         return (False, 'EncodingClient: connection error')
 
-    return returnFromJelly(status, response)
+    return (True ,response)
 
 def setVideoFilters(idnr, filters):
     """Set a number of possible video filters & processing operations

Modified: branches/rel-1/freevo/src/video/plugins/dvdbackup.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/dvdbackup.py        (original)
+++ branches/rel-1/freevo/src/video/plugins/dvdbackup.py        Sun Jan 20 
07:48:33 2008
@@ -124,7 +124,7 @@
         idnr = resp
 
         #ask for possible containers and set the first one (should be avi), we 
will get a list
-        (status, resp) = getContainerCAP(idnr)
+        (status, resp) = getContainerCAP()
 
         if not status:
             self.error(resp)
@@ -139,7 +139,7 @@
             return
 
         #ask for possible videocodec and set the first one (should be mpeg4), 
we will get a list
-        (status, resp) = getVideoCodecCAP(idnr)
+        (status, resp) = getVideoCodecCAP()
 
         if not status:
             self.error(resp)
@@ -156,7 +156,7 @@
         #ask for possible audiocodec and set the first one (should be mp3), we 
will get a list
         #Audiocodec call isn't necessary atm, it defaults to 128 kbit mp3, but 
this might change in the future
         #so we play safe
-        (status, resp) = getAudioCodecCAP(idnr)
+        (status, resp) = getAudioCodecCAP()
 
         if not status:
             self.error(resp)

Modified: branches/rel-1/freevo/src/video/plugins/reencode.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/reencode.py (original)
+++ branches/rel-1/freevo/src/video/plugins/reencode.py Sun Jan 20 07:48:33 2008
@@ -35,7 +35,6 @@
 import os
 import config
 from video.encodingclient import *
-from encodingcore import ContainerCapList, VideoCodecList, AudioCodecList, 
VideoFilters
 from gui.AlertBox import AlertBox
 from gui.PopupBox import PopupBox
 
@@ -177,7 +176,7 @@
     def mod_container(self, arg=None, menuw=None):
         _debug_('mod_container(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
-        for container in ContainerCapList:
+        for container in getContainerCAP()[1]:
             items.append(menu.MenuItem(container, action=self.alter_prop, 
arg=('container', container)))
         container_menu = menu.Menu(_('Modify Container'), items, item_types = 
'video encoding menu')
         container_menu.infoitem = self
@@ -197,7 +196,7 @@
     def mod_videocodec(self, arg=None, menuw=None):
         _debug_('mod_videocodec(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
-        for videocodec in VideoCodecList:
+        for videocodec in getVideoCodecCAP()[1]:
             items.append(menu.MenuItem(videocodec, action=self.alter_prop, 
arg=('videocodec', videocodec)))
         videocodec_menu = menu.Menu(_('Modify Video Codec'), items, item_types 
= 'video encoding menu')
         videocodec_menu.infoitem = self
@@ -217,7 +216,7 @@
     def mod_audiocodec(self, arg=None, menuw=None):
         _debug_('mod_audiocodec(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
-        for audiocodec in AudioCodecList:
+        for audiocodec in getAudioCodecCAP()[1]:
             items.append(menu.MenuItem(audiocodec, action=self.alter_prop, 
arg=('audiocodec', audiocodec)))
         audiocodec_menu = menu.Menu(_('Modify Video Codec'), items, item_types 
= 'video encoding menu')
         audiocodec_menu.infoitem = self
@@ -257,7 +256,7 @@
     def mod_videofilter(self, arg=None, menuw=None):
         _debug_('mod_videofilter(self, arg=%r, menuw=%r)' % (arg, menuw), 1)
         items = []
-        for videofilter in VideoFilters:
+        for videofilter in getVideoFiltersCAP()[1]:
             items.append(menu.MenuItem(videofilter, action=self.alter_prop, 
arg=('videofilter', videofilter)))
         videofilter_menu = menu.Menu(_('Modify Video Filter'), items, 
item_types = 'video encoding menu')
         videofilter_menu.infoitem = self
@@ -293,7 +292,7 @@
             self.profile['videocodec'] = 'MPEG 4 (lavc)'
             self.profile['altprofile'] = 
'vcodec=mpeg4:mbd=2:cmp=2:subcmp=2:trell=yes:v4mv=yes:vglobal=1'
             self.profile['videobitrate'] = 1200
-            self.profile['audiocodec'] = 'aac (iPod)'
+            self.profile['audiocodec'] = 'AAC (iPod)'
             self.profile['audiobitrate'] = 192
             self.profile['numpasses'] = 2
             self.profile['videofilter'] = 'ipod'
@@ -303,7 +302,7 @@
             self.profile['videocodec'] = 'MPEG 2 (lavc)'
             self.profile['altprofile'] = None
             self.profile['videobitrate'] = 5200
-            self.profile['audiocodec'] = 'ac3'
+            self.profile['audiocodec'] = 'AC3'
             self.profile['audiobitrate'] = 224
             self.profile['numpasses'] = 1
             self.profile['videofilter'] = 'None'

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to