Skip to content

Commit aef5426

Browse files
authored
Add files via upload
1 parent b7ada09 commit aef5426

File tree

6 files changed

+240
-186
lines changed

6 files changed

+240
-186
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.8
1+
1.9

Python Version/DatamoshLib/FFG_effects/basic_modes.py

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from pathlib import Path
44
import numpy as np
55
DIRPATH = Path(os.path.dirname(os.path.realpath(__file__)))
6-
ffgac=str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffgac"
7-
ffedit=str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffedit"
6+
ffgac = str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffgac"
7+
ffedit = str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffedit"
88

9-
def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0, e=0, vh=0, gop=1000):
9+
def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0, e=0, vh=0, gop=1000, r=0, f=0):
1010
def get_vectors(input_video):
1111
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -mpv_flags +nopimb+forcemv -qscale:v 0 -g "{gop}"' +
1212
' -vcodec mpeg2video -f rawvideo -y tmp.mpg', shell=True)
@@ -118,6 +118,34 @@ def rise(output):
118118
fp.write(out_data)
119119
fp.close()
120120
shutil.rmtree("cache")
121+
def water_bloom(output):
122+
if os.path.isdir("cache"):
123+
shutil.rmtree("cache")
124+
os.mkdir("cache")
125+
base=os.path.basename(input_video)
126+
fin="cache/"+base[:-4]+".mpg"
127+
qua=''
128+
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -vcodec mpeg2video -f rawvideo -mpv_flags +nopimb -qscale:v 6 -r 30 -g "{gop}" -y "{fin}"')
129+
os.mkdir("cache/raws")
130+
framelist=[]
131+
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache/raws/frames_%04d.raw')
132+
repeat=r
133+
po=f-1
134+
frames=os.listdir("cache/raws")
135+
for i in frames[:po]:
136+
framelist.append(i)
137+
for i in range(repeat):
138+
framelist.append(frames[po])
139+
for i in frames[po:]:
140+
framelist.append(i)
141+
out_data = b''
142+
for fn in framelist:
143+
with open("cache/raws/"+fn, 'rb') as fp:
144+
out_data += fp.read()
145+
with open(output, 'wb') as fp:
146+
fp.write(out_data)
147+
fp.close()
148+
shutil.rmtree("cache")
121149
def average(frames):
122150
if not frames:
123151
return []
@@ -152,3 +180,5 @@ def movement(frames):
152180
shuffle(output)
153181
elif(mode==5):
154182
rise(output)
183+
elif(mode==6):
184+
water_bloom(output)

Python Version/DatamoshLib/FFG_effects/external_script.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
import os, subprocess
33
from pathlib import Path
44
DIRPATH = Path(os.path.dirname(os.path.realpath(__file__)))
5-
ffgac=str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffgac"
6-
ffedit=str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffedit"
5+
ffgac = str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffgac"
6+
ffedit = str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffedit"
7+
78
def mosh(input_video, output_video, mode, effect='', scriptfile='', gop=1000):
89
if mode==1:
910
script_path=scriptfile
1011
elif mode==2:
11-
script_path=str(DIRPATH).replace(os.sep, '/')+"/jscripts/"+effect+".js"
12+
script_path = str(DIRPATH).replace(os.sep, '/')+"/jscripts/"+effect+".js"
1213
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -mpv_flags +nopimb+forcemv -qscale:v 0 -b:v 20M -minrate 20M -maxrate 20M -bufsize 2M -g "{gop}"' +
1314
' -vcodec mpeg2video -f rawvideo -y tmp.mpg', shell=True)
1415
subprocess.call(f'"{ffedit}" -i tmp.mpg -f mv -s "{script_path}" -o "{output_video}"', shell=True)

Python Version/DatamoshLib/Tomato/tomato.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def mosh(infile, outfile, m, c, n, a, f, k):
2323
audio = a
2424
firstframe = f
2525
kill = k
26+
2627
if filein is None or os.path.exists(filein) == False:
2728
print("> step 0/5: valid input file required!")
2829
print("use -h to see help")
@@ -125,15 +126,33 @@ def bstream_until_marker(bfilein, bfileout, marker=0, startpos=0):
125126

126127
# keep first video frame or not
127128
if firstframe:
129+
if mode == "bloom":
130+
if positframes==1:
131+
positframes=2
132+
for x in l[0:positframes]:
133+
if x[2] == 'video':
134+
clean.append(x)
135+
# clean the list by killing "big" frames
136+
for x in l[positframes:]:
137+
if x[1] <= (max_frame_size * kill) :
138+
clean.append(x)
139+
else:
140+
for x in l[0:10]:
141+
if x[2] == 'video':
142+
clean.append(x)
143+
# clean the list by killing "big" frames
144+
for x in l[10:]:
145+
if x[1] <= (max_frame_size * kill) :
146+
clean.append(x)
147+
else:
128148
for x in l:
129149
if x[2] == 'video':
130150
clean.append(x)
131151
break
132-
133-
# clean the list by killing "big" frames
134-
for x in l:
135-
if x[1] <= (max_frame_size * kill) :
136-
clean.append(x)
152+
# clean the list by killing "big" frames
153+
for x in l:
154+
if x[1] <= (max_frame_size * kill) :
155+
clean.append(x)
137156
# FX modes
138157
if mode == "void":
139158
print('> step 3/5 : mode void')

0 commit comments

Comments
 (0)