modified: spffq.py
[GalaxyCodeBases.git] / etc / vapoursynth / t.vpy
blobb2cfbd10efde54264d8db3e568a62c0b33222c1b
1 import vapoursynth as vs
2 core = vs.get_core()
4 # only needed when libf3kdb.dylib wasn't installed
5 #core.std.LoadPlugin("/usr/local/Cellar/f3kdb/HEAD/lib/libf3kdb.dylib")
6 #core.std.LoadPlugin("/Users/Galaxy/git/ffms2/libffms2.4.dylib")
8 # http://forum.doom9.org/archive/index.php/t-165771-p-4.html
9 def fadeout(theclip):
10     fade_input = theclip
11     fadetime = 0.5
12     fadeframes = fadetime * theclip.fps_num / theclip.fps_den
13     beginframes = theclip.num_frames-1 - fadeframes
14     blank = core.std.BlankClip(clip=fade_input, length=1, color=[0, 128, 128]) # assumes you're working with 8 bit YUV
15     fade_frames = []
16     for i in range(fade_input.num_frames):
17         if (i <= beginframes) :
18             fade_frames.append(fade_input[i])
19         else :
20             fade_frames.append(core.std.Merge(clipa=fade_input[i], clipb=blank, weight=[(i-beginframes)/fadeframes]))
21     fade_output = core.std.Splice(clips=fade_frames)
22     return fade_output
24 def fadein(theclip):
25     fade_input = theclip
26     fadetime = 1
27     fadeframes = fadetime * theclip.fps_num / theclip.fps_den
28     blank = core.std.BlankClip(clip=fade_input, length=1, color=[0, 128, 128]) # assumes you're working with 8 bit YUV
29     fade_frames = []
30     for i in range(fade_input.num_frames):
31         if (i > fadeframes) :
32             fade_frames.append(fade_input[i])
33         else :
34             fade_frames.append(core.std.Merge(clipa=fade_input[i], clipb=blank, weight=[(fadeframes-i)/fadeframes]))
35     fade_output = core.std.Splice(clips=fade_frames)
36     return fade_output
38 p1 = core.ffms2.Source(source='2.mp4')
39 p1 = core.std.Turn180(p1)
40 #p1 = core.text.ClipInfo(p1)
41 p1 = core.std.AddBorders(p1,top=124,bottom=124) # 568x320
42 #p1 = fadein(p1)
43 p1 = fadeout(p1)
44 #p1 = core.text.ClipInfo(p1)
46 p2 = core.ffms2.Source(source='3.mp4')
47 p2 = core.std.Turn180(p2)
48 #p2 = core.text.ClipInfo(p2)
49 p2 = core.std.AddBorders(p2,top=124,bottom=124)
50 p2 = fadein(p2)
51 p2 = fadeout(p2)
53 p3 = core.ffms2.Source(source='9.mp4')
54 p3 = core.std.Transpose(p3)
55 p3 = core.std.FlipHorizontal(p3)
56 #p3 = core.text.ClipInfo(p3)
57 p3 = core.std.AddBorders(p3,left=124,right=124)
58 p3 = fadein(p3)
59 #p3 = fadeout(p3)
62 #ret = core.std.Transpose(ret)
63 ret = core.std.Splice([p1,p2,p3])
64 ret.set_output()
66 # find . -name '*.mp4'|while read a;do echo "file $a"; done > mylist.txt
67 # ffmpeg -f concat -i mylist.txt -c copy output.mp4
68 # vspipe --y4m t.vpy - | mpv -
69 # vspipe --y4m t.vpy - | x264 --demuxer y4m - --output encoded.mkv
70 # ffmpeg -i output.mp4 -i encoded.mkv # see the list of stream numbers
71 # ffmpeg -i output.mp4 -i encoded.mkv -map 1:0 -map 0:1 -acodec copy -vcodec copy -shortest mg.mp4
72 # The -shortest option will cause the output duration to match the duration of the shortest input stream. http://ffmpeg.org/ffmpeg.html#Advanced-options
74 # proxychains4 -q brew tap mpv-player/mpv
75 # brew install --with-vapoursynth mpv
76 # proxychains4 git clone https://github.com/FFMS/ffms2.git
77 # ./configure --enable-shared && make
78 # cp ./src/core/.libs/libffms2.4.dylib /usr/local/Cellar/vapoursynth/26/lib/vapoursynth/