-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathIVF_pipeline.py
60 lines (52 loc) · 2.13 KB
/
IVF_pipeline.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*-
from generalBP import BPDarkCorner, BPEffect, BPFilter, BPInverseColor, BPjiugongge, BPMirror, BPMove, BPPolygon
from generalBP import BPReflect, BPRipple, BPScale, BPshake
from AEEffect import AEScroll
import BPThread, blueprintBase
from xyl_leon.LYBF_scroll import CLYBF_Scroll
g_effect_dict = {
"DarkCorner" : BPDarkCorner.CBPDarkCorner,
"Rotate" : BPEffect.CBPEffectRotate,
"Filter" : BPFilter.CBPFilter,
"scroll" : CLYBF_Scroll,
"InverseColor" : BPInverseColor.CBPInverseColor,
"jiugongge" : BPjiugongge.CBPJiuGongGe,
"Mirror" : BPMirror.CBPMirror,
"Move" : BPMove.CBPMove,
"Polygon" : BPPolygon.CBPPolygon,
"Reflect" : BPReflect.CBPReflect,
"Ripple" : BPRipple.CBPRipple,
"Scale" : BPScale.CBPScale,
"Shake" : BPshake.CBPShake,
"AEScroll" : AEScroll.CAEScroll
}
def IVF_pipeline(inputElement, duration, effect_list, effectConfig):
outputVideo = inputElement
for i, effectName in enumerate(effect_list):
if (effectName not in g_effect_dict.keys()):
raise Exception("illegal effect name")
effectClass = g_effect_dict[effectName]
configDict = effectConfig.get(effectName, dict())
outputDict = blueprintBase.make_Video(effectClass, outputVideo, duration, configDict)
# print(outputDict)
outputVideo = outputDict['outputVideo']
return outputVideo
# 异步实现,适合有多个素材需要处理的场景
def IVF_pipeline_asyn(inputElement, duration, effect_list, effectConfig):
t = BPThread.BPThread(IVF_pipeline, inputElement, duration, effect_list, effectConfig)
t.setDaemon(True)
t.start()
return t
def IVF_pipeline_asyn_join(t):
return t.join()
#### TEST PROGRAM
def test():
# inputElement = "https://videofactory.oss-cn-shanghai.aliyuncs.com/ios/video/mv_6.mp4"
inputElement = "https://cgptest.oss-cn-shanghai.aliyuncs.com/meise/3.jpg"
duration = 3000
effect_list = ['AEScroll', "DarkCorner", "Mirror"]
effectConfig = dict()
outputVideo = IVF_pipeline(inputElement, duration, effect_list, effectConfig)
print(outputVideo)
if __name__=="__main__":
test()