Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaker authored Aug 22, 2020
1 parent 3ca65dd commit 32f9099
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 50 deletions.
26 changes: 15 additions & 11 deletions ffmpegInfoParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])])
Expand All @@ -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)
5 changes: 5 additions & 0 deletions ffmpegService.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'

Expand Down Expand Up @@ -543,6 +546,8 @@ def encodeWorker():
statusCallback)
except Exception as e:
print(e)
import traceback
traceback.print_exc()

self.encodeWorkers=[]
for _ in range(encodeWorkerCount):
Expand Down
78 changes: 40 additions & 38 deletions filterSpec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions mergeSelectionController.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__':
Expand Down
2 changes: 1 addition & 1 deletion mergeSelectionUi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 32f9099

Please sign in to comment.