diff --git a/ffmpegInfoParser.py b/ffmpegInfoParser.py index c8f181f..54078da 100644 --- a/ffmpegInfoParser.py +++ b/ffmpegInfoParser.py @@ -10,16 +10,17 @@ class VideoInfo: height:int width:int -def getVideoInfo(filename): +def getVideoInfo(filename,filters=None): state=None stats= dict(filename=filename) - proc = sp.Popen(['ffmpeg','-i',filename],stdout=sp.PIPE,stderr=sp.PIPE) + if filters is None: + proc = sp.Popen(['ffmpeg','-i',filename],stdout=sp.PIPE,stderr=sp.PIPE) + else: + proc = sp.Popen(['ffmpeg','-i',filename,'-filter_complex', filters,'-frames:v','1','-f','null','-'],stdout=sp.PIPE,stderr=sp.PIPE) + outs,errs = proc.communicate() for errLine in errs.split(b'\n'): for errElem in [x.strip() for x in errLine.split(b',')]: - - - if errElem.startswith(b'Duration:'): timeParts = [float(x) for x in errElem.split()[-1].split(b':')] stats['duration'] = sum([t*m for t,m in zip(timeParts[::-1],[1,60,60*60,60*60*60])]) @@ -36,11 +37,14 @@ def getVideoInfo(filename): elif errElem.endswith(b'tbr'): stats['tbr']=float(errElem.split(b' ')[0]) if b'x' in errElem: - w,h = errElem.split(b' ')[0].split(b'x') - w=int(w) - h=int(h) - - stats['height'] = h - stats['width'] = w + try: + w,h = errElem.split(b' ')[0].split(b'x') + w=int(w) + h=int(h) + + stats['height'] = h + stats['width'] = w + except: + pass return VideoInfo(**stats) diff --git a/ffmpegService.py b/ffmpegService.py index dbbb278..07e05f8 100644 --- a/ffmpegService.py +++ b/ffmpegService.py @@ -366,7 +366,9 @@ def encodeWorker(): fileSequence=[] clipDimensions = [] + print(requestId,mode,seqClips,options,filenamePrefix,statusCallback) for i,(rid,clipfilename,s,e,filterexp) in enumerate(seqClips): + print(i,(rid,clipfilename,s,e,filterexp)) expectedTimes.append(e-s) videoInfo = ffmpegInfoParser.getVideoInfo(cleanFilenameForFfmpeg(clipfilename)) videoh=videoInfo.height @@ -380,6 +382,7 @@ def encodeWorker(): totalEncodedSeconds = 0 for i,(etime,(videow,videoh),(rid,clipfilename,start,end,filterexp)) in enumerate(zip(expectedTimes,clipDimensions,seqClips)): + print(i,(etime,(videow,videoh),(rid,clipfilename,start,end,filterexp))) if filterexp=='': filterexp='null' @@ -543,6 +546,8 @@ def encodeWorker(): statusCallback) except Exception as e: print(e) + import traceback + traceback.print_exc() self.encodeWorkers=[] for _ in range(encodeWorkerCount): diff --git a/filterSpec.py b/filterSpec.py index baa19eb..375e7cb 100644 --- a/filterSpec.py +++ b/filterSpec.py @@ -12,6 +12,46 @@ ] selectableFilters = [ + + { + "name": "crop", + "filter": "crop", + "params": [ + { + "n": "x", + "d": 0, + "type": "int", + "range": None, + "rectProp": "x", + "inc": 10, + }, + { + "n": "y", + "d": 0, + "type": "int", + "range": None, + "rectProp": "y", + "inc": 10, + }, + { + "n": "w", + "d": 100, + "type": "int", + "range": None, + "rectProp": "w", + "inc": 10, + }, + { + "n": "h", + "d": 100, + "type": "int", + "range": None, + "rectProp": "h", + "inc": 10, + }, + ], + }, + { "name": "subtitles", "filter": "subtitles", @@ -661,44 +701,6 @@ ], }, - { - "name": "crop", - "filter": "crop", - "params": [ - { - "n": "x", - "d": 0, - "type": "int", - "range": None, - "rectProp": "x", - "inc": 10, - }, - { - "n": "y", - "d": 0, - "type": "int", - "range": None, - "rectProp": "y", - "inc": 10, - }, - { - "n": "w", - "d": 100, - "type": "int", - "range": None, - "rectProp": "w", - "inc": 10, - }, - { - "n": "h", - "d": 100, - "type": "int", - "range": None, - "rectProp": "h", - "inc": 10, - }, - ], - }, { "name": "drawtext", diff --git a/mergeSelectionController.py b/mergeSelectionController.py index d068a2a..d848ac7 100644 --- a/mergeSelectionController.py +++ b/mergeSelectionController.py @@ -15,6 +15,7 @@ def requestPreviewFrame(self,rid,filename,timestamp,filterexp,size,callback): self.ffmpegService.requestPreviewFrame(rid,filename,timestamp,filterexp,size,callback) def encode(self,requestId,mode,seq,options,filenamePrefix,statusCallback): + print('encode',requestId,mode,seq,options,filenamePrefix) self.ffmpegService.encode(requestId,mode,seq,options,filenamePrefix,statusCallback) if __name__ == '__main__': diff --git a/mergeSelectionUi.py b/mergeSelectionUi.py index c30316b..e379688 100644 --- a/mergeSelectionUi.py +++ b/mergeSelectionUi.py @@ -285,7 +285,7 @@ def __init__(self, master=None, *args, **kwargs): self.maximumSizeVar.set('0.0') self.maximumWidthVar.set('1280') - self.transDurationVar.set('0.5') + self.transDurationVar.set('0.0') self.transStyles = ['fade','wipeleft','wiperight','wipeup' ,'wipedown','slideleft','slideright','slideup','slidedown'