Duncan Webb ha scritto: > A Mennucc wrote: >> 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)
now it works; I attach the patch (this patch contains also the patch in previous email, re: unsafe tmp usage) this patch is really useful for me: 1) since programs are quite randomized in Italy, I use a huge PADDING in recordin; but, when I transcode, I do want to delete all extra stuff 2) once I recorded a show , but before that show there was a movie in 16/9 , with huge black bands: when I tried to reencode that show, cropdetect was done only on the preceding movie, so that the show was then cropped to 16/9 :-( . The good point in my patch is that cropdetect, also, is done from the starting point that the user decides. > This is not the correct way to use mencoder for cutting av media. Use > the edl (edit decision list). There is some code in the commdetectserver > that may help. In designing this code, I thought about a future development in this respect: the variable 'timeslice' is a list , now this list has only two elements , but the idea is that it may contain the EDL list (when EDL will be more reliable :-) a.
--- /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 18:34:19.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 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 __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_items = [ menu.MenuItem(_('Do not set'), action=which, arg=None),]
+ 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.append(menu.MenuItem(time, action=which, arg=sec))
+ encoding_menu = menu.Menu(_('Select Time'), menu_items, item_types = 'video encoding menu')
+ encoding_menu.infoitem = self
+ menuw.pushmenu(encoding_menu)
+ menuw.refresh()
+
+ 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 17:48:36.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 18:30:03.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', str(timeslice[0])]
+ start = timeslice[0]
+ if timeslice[1] :
+ self.timeslice_mencoder += ['-endpos', str(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 17:48:36.000000000 +0200
@@ -76,8 +76,6 @@
except:
print String(text)
-tmppath = '/tmp/encodingserver'
-
jam = jellyToXML
unjam = unjellyFromXML
@@ -136,7 +134,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()))
@@ -216,13 +222,13 @@
jlist = self.queue.listJobs()
return (True, jam(jlist))
-
+import tempfile
+
def main():
global DEBUG
- #check for /tmp/encodingserver and if it doesn't exist make it
- if not (os.path.exists(tmppath) and os.path.isdir(tmppath)):
- os.mkdir(tmppath)
- #chdir to /tmp/encodingserver
+
+ tmppath = tempfile.mkdtemp(prefix = 'encodeserver')
+ #chdir
os.chdir(tmppath)
app = Application("EncodingServer")
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
