mirror of
https://github.com/Akascape/Datamosher-Pro.git
synced 2025-12-13 03:39:59 +01:00
Add files via upload
This commit is contained in:
@@ -2,9 +2,10 @@
|
|||||||
import os, shutil, subprocess, random, json
|
import os, shutil, subprocess, random, json
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
DIRPATH = Path(os.path.dirname(os.path.realpath(__file__)))
|
DIRPATH = Path(os.path.dirname(os.path.realpath(__file__)))
|
||||||
ffgac = str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffgac"
|
ffgac = os.path.join(str(DIRPATH.parent.parent),"FFglitch","ffgac")
|
||||||
ffedit = str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffedit"
|
ffedit = os.path.join(str(DIRPATH.parent.parent),"FFglitch","ffedit")
|
||||||
|
|
||||||
def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0, e=0, vh=0, gop=1000, r=0, f=0):
|
def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0, e=0, vh=0, gop=1000, r=0, f=0):
|
||||||
def get_vectors(input_video):
|
def get_vectors(input_video):
|
||||||
@@ -24,6 +25,7 @@ def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0,
|
|||||||
except:
|
except:
|
||||||
vectors.append([])
|
vectors.append([])
|
||||||
return vectors
|
return vectors
|
||||||
|
|
||||||
def apply_vectors(vectors, input_video, output_video, method='add'):
|
def apply_vectors(vectors, input_video, output_video, method='add'):
|
||||||
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -mpv_flags +nopimb+forcemv -qscale:v 0 -g "{gop}"' +
|
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -mpv_flags +nopimb+forcemv -qscale:v 0 -g "{gop}"' +
|
||||||
' -vcodec mpeg2video -f rawvideo -y tmp.mpg', shell=True)
|
' -vcodec mpeg2video -f rawvideo -y tmp.mpg', shell=True)
|
||||||
@@ -56,17 +58,18 @@ def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0,
|
|||||||
subprocess.call(f'"{ffedit}" -i tmp.mpg -f mv -s "{script_path}" -o "{output_video}"', shell=True)
|
subprocess.call(f'"{ffedit}" -i tmp.mpg -f mv -s "{script_path}" -o "{output_video}"', shell=True)
|
||||||
os.remove('apply_vectors.js')
|
os.remove('apply_vectors.js')
|
||||||
os.remove('tmp.mpg')
|
os.remove('tmp.mpg')
|
||||||
|
|
||||||
def shuffle(output):
|
def shuffle(output):
|
||||||
if os.path.isdir("cache"):
|
if os.path.isdir("cache_ffg"):
|
||||||
shutil.rmtree("cache")
|
shutil.rmtree("cache_ffg")
|
||||||
os.mkdir("cache")
|
os.mkdir("cache_ffg")
|
||||||
base=os.path.basename(input_video)
|
base = os.path.basename(input_video)
|
||||||
fin="cache/"+base[:-4]+".mpg"
|
fin = os.path.join("cache_ffg",base[:-4]+".mpg")
|
||||||
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -vcodec mpeg2video -f rawvideo -mpv_flags +nopimb -qscale:v 6 -r 30 -g "{gop}" -y "{fin}"')
|
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -vcodec mpeg2video -f rawvideo -mpv_flags +nopimb -qscale:v 6 -r 30 -g "{gop}" -y "{fin}"')
|
||||||
os.mkdir("cache/raws")
|
os.mkdir(os.path.join("cache_ffg","raws"))
|
||||||
framelist=[]
|
framelist=[]
|
||||||
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache/raws/frames_%04d.raw')
|
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache_ffg/raws/frames_%04d.raw')
|
||||||
frames=os.listdir("cache/raws")
|
frames=os.listdir(os.path.join("cache_ffg","raws"))
|
||||||
siz=size
|
siz=size
|
||||||
framelist.extend(frames)
|
framelist.extend(frames)
|
||||||
chunked_list=[]
|
chunked_list=[]
|
||||||
@@ -83,55 +86,57 @@ def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0,
|
|||||||
framelist.append(j)
|
framelist.append(j)
|
||||||
out_data = b''
|
out_data = b''
|
||||||
for fn in framelist:
|
for fn in framelist:
|
||||||
with open("cache/raws/"+fn, 'rb') as fp:
|
with open(os.path.join("cache_ffg","raws",fn), 'rb') as fp:
|
||||||
out_data += fp.read()
|
out_data += fp.read()
|
||||||
with open(output, 'wb+') as fp:
|
with open(output, 'wb+') as fp:
|
||||||
fp.write(out_data)
|
fp.write(out_data)
|
||||||
fp.close()
|
fp.close()
|
||||||
shutil.rmtree("cache")
|
shutil.rmtree("cache_ffg")
|
||||||
|
|
||||||
def rise(output):
|
def rise(output):
|
||||||
if os.path.isdir("cache"):
|
if os.path.isdir("cache_ffg"):
|
||||||
shutil.rmtree("cache")
|
shutil.rmtree("cache_ffg")
|
||||||
os.mkdir("cache")
|
os.mkdir("cache_ffg")
|
||||||
base=os.path.basename(input_video)
|
base = os.path.basename(input_video)
|
||||||
fin="cache/"+base[:-4]+".mpg"
|
fin = os.path.join("cache_ffg",base[:-4]+".mpg")
|
||||||
qua=''
|
qua=''
|
||||||
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -vcodec mpeg2video -f rawvideo -mpv_flags +nopimb -qscale:v 6 -r 30 -g "{gop}" -y "{fin}"')
|
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -vcodec mpeg2video -f rawvideo -mpv_flags +nopimb -qscale:v 6 -r 30 -g "{gop}" -y "{fin}"')
|
||||||
os.mkdir("cache/raws")
|
os.mkdir(os.path.join("cache_ffg","raws"))
|
||||||
framelist=[]
|
framelist=[]
|
||||||
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache/raws/frames_%04d.raw')
|
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache_ffg/raws/frames_%04d.raw')
|
||||||
kil=e
|
kil=e
|
||||||
po=s
|
po=s
|
||||||
if po==0:
|
if po==0:
|
||||||
po=1
|
po=1
|
||||||
frames=os.listdir("cache/raws")
|
frames=os.listdir(os.path.join("cache_ffg","raws"))
|
||||||
for i in frames[po:(po+kil)]:
|
for i in frames[po:(po+kil)]:
|
||||||
os.remove("cache/raws/"+i)
|
os.remove(os.path.join("cache_ffg","raws",i))
|
||||||
frames.clear()
|
frames.clear()
|
||||||
frames=os.listdir("cache/raws")
|
frames=os.listdir(os.path.join("cache_ffg","raws"))
|
||||||
framelist.extend(frames)
|
framelist.extend(frames)
|
||||||
out_data = b''
|
out_data = b''
|
||||||
for fn in framelist:
|
for fn in framelist:
|
||||||
with open("cache/raws/"+fn, 'rb') as fp:
|
with open(os.path.join("cache_ffg","raws",fn), 'rb') as fp:
|
||||||
out_data += fp.read()
|
out_data += fp.read()
|
||||||
with open(output, 'wb') as fp:
|
with open(output, 'wb') as fp:
|
||||||
fp.write(out_data)
|
fp.write(out_data)
|
||||||
fp.close()
|
fp.close()
|
||||||
shutil.rmtree("cache")
|
shutil.rmtree("cache_ffg")
|
||||||
|
|
||||||
def water_bloom(output):
|
def water_bloom(output):
|
||||||
if os.path.isdir("cache"):
|
if os.path.isdir("cache_ffg"):
|
||||||
shutil.rmtree("cache")
|
shutil.rmtree("cache_ffg")
|
||||||
os.mkdir("cache")
|
os.mkdir("cache_ffg")
|
||||||
base=os.path.basename(input_video)
|
base = os.path.basename(input_video)
|
||||||
fin="cache/"+base[:-4]+".mpg"
|
fin = os.path.join("cache_ffg",base[:-4]+".mpg")
|
||||||
qua=''
|
qua=''
|
||||||
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -vcodec mpeg2video -f rawvideo -mpv_flags +nopimb -qscale:v 6 -r 30 -g "{gop}" -y "{fin}"')
|
subprocess.call(f'"{ffgac}" -i "{input_video}" -an -vcodec mpeg2video -f rawvideo -mpv_flags +nopimb -qscale:v 6 -r 30 -g "{gop}" -y "{fin}"')
|
||||||
os.mkdir("cache/raws")
|
os.mkdir("cache_ffg/raws")
|
||||||
framelist=[]
|
framelist=[]
|
||||||
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache/raws/frames_%04d.raw')
|
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache_ffg/raws/frames_%04d.raw')
|
||||||
repeat=r
|
repeat=r
|
||||||
po=f-1
|
po=f-1
|
||||||
frames=os.listdir("cache/raws")
|
frames=os.listdir(os.path.join("cache_ffg","raws"))
|
||||||
for i in frames[:po]:
|
for i in frames[:po]:
|
||||||
framelist.append(i)
|
framelist.append(i)
|
||||||
for i in range(repeat):
|
for i in range(repeat):
|
||||||
@@ -140,21 +145,24 @@ def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0,
|
|||||||
framelist.append(i)
|
framelist.append(i)
|
||||||
out_data = b''
|
out_data = b''
|
||||||
for fn in framelist:
|
for fn in framelist:
|
||||||
with open("cache/raws/"+fn, 'rb') as fp:
|
with open(os.path.join("cache_ffg","raws",fn), 'rb') as fp:
|
||||||
out_data += fp.read()
|
out_data += fp.read()
|
||||||
with open(output, 'wb') as fp:
|
with open(output, 'wb') as fp:
|
||||||
fp.write(out_data)
|
fp.write(out_data)
|
||||||
fp.close()
|
fp.close()
|
||||||
shutil.rmtree("cache")
|
shutil.rmtree("cache_ffg")
|
||||||
|
|
||||||
def average(frames):
|
def average(frames):
|
||||||
if not frames:
|
if not frames:
|
||||||
return []
|
return []
|
||||||
return np.mean(np.array([x for x in frames if x != []]), axis=0).tolist()
|
return np.mean(np.array([x for x in frames if x != []]), axis=0).tolist()
|
||||||
|
|
||||||
def fluid(frames):
|
def fluid(frames):
|
||||||
average_length = fluidity
|
average_length = fluidity
|
||||||
if average_length==1:
|
if average_length==1:
|
||||||
average_length=2
|
average_length=2
|
||||||
return [average(frames[i + 1 - average_length: i + 1]) for i in range(len(frames))]
|
return [average(frames[i + 1 - average_length: i + 1]) for i in range(len(frames))]
|
||||||
|
|
||||||
def movement(frames):
|
def movement(frames):
|
||||||
for frame in frames:
|
for frame in frames:
|
||||||
if not frame:
|
if not frame:
|
||||||
@@ -163,6 +171,7 @@ def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0,
|
|||||||
for col in row:
|
for col in row:
|
||||||
col[vh] = 0
|
col[vh] = 0
|
||||||
return frames
|
return frames
|
||||||
|
|
||||||
if(mode==1):
|
if(mode==1):
|
||||||
transfer_to=input_video
|
transfer_to=input_video
|
||||||
vectors = []
|
vectors = []
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
#Author: Akash Bora
|
#Author: Akash Bora
|
||||||
import os, subprocess
|
import os, subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
DIRPATH = Path(os.path.dirname(os.path.realpath(__file__)))
|
DIRPATH = Path(os.path.dirname(os.path.realpath(__file__)))
|
||||||
ffgac = str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffgac"
|
ffgac = os.path.join(str(DIRPATH.parent.parent),"FFglitch","ffgac")
|
||||||
ffedit = str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffedit"
|
ffedit = os.path.join(str(DIRPATH.parent.parent),"FFglitch","ffedit")
|
||||||
|
|
||||||
def mosh(input_video, output_video, mode, effect='', scriptfile='', gop=1000):
|
def mosh(input_video, output_video, mode, effect='', scriptfile='', gop=1000):
|
||||||
|
|
||||||
if mode==1:
|
if mode==1:
|
||||||
script_path=scriptfile
|
script_path = scriptfile
|
||||||
elif mode==2:
|
elif mode==2:
|
||||||
script_path = str(DIRPATH).replace(os.sep, '/')+"/jscripts/"+effect+".js"
|
script_path = os.path.join(str(DIRPATH),"jscripts",effect+".js")
|
||||||
|
|
||||||
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}"' +
|
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}"' +
|
||||||
' -vcodec mpeg2video -f rawvideo -y tmp.mpg', shell=True)
|
' -vcodec mpeg2video -f rawvideo -y tmp.mpg', shell=True)
|
||||||
subprocess.call(f'"{ffedit}" -i tmp.mpg -f mv -s "{script_path}" -o "{output_video}"', shell=True)
|
subprocess.call(f'"{ffedit}" -i tmp.mpg -f mv -s "{script_path}" -o "{output_video}"', shell=True)
|
||||||
|
|||||||
Reference in New Issue
Block a user