Compare commits
516 Commits
Datamosher
...
Datamosher
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a964ecf891 | ||
|
|
7933558b15 | ||
|
|
ce394fcd90 | ||
|
|
2150cd6019 | ||
|
|
b368dfc9c7 | ||
|
|
816d1150bd | ||
|
|
1d45e22e55 | ||
|
|
9755263e6e | ||
|
|
8e4ddc83e9 | ||
|
|
cfdb269b1e | ||
|
|
6c4823fe81 | ||
|
|
2e45e67162 | ||
|
|
f7c62a5944 | ||
|
|
18b043f4be | ||
|
|
684f036fc7 | ||
|
|
4897db579b | ||
|
|
420ff634a6 | ||
|
|
2dda202bf2 | ||
|
|
5e0183ccdc | ||
|
|
f4dddd98be | ||
|
|
3ce6cfdbc7 | ||
|
|
6ef19a1abc | ||
|
|
e9506e15d9 | ||
|
|
ad210e74d5 | ||
|
|
227edad13b | ||
|
|
c815190585 | ||
|
|
95181d47ca | ||
|
|
7e4d5f7de2 | ||
|
|
a22762a278 | ||
|
|
4c079e9082 | ||
|
|
68729edfce | ||
|
|
e7deabc4f9 | ||
|
|
0d55f2e986 | ||
|
|
32fef121c2 | ||
|
|
5698e82263 | ||
|
|
4eff80cb69 | ||
|
|
b010bbbcf7 | ||
|
|
17ad34dc0b | ||
|
|
e3d0d4b7fd | ||
|
|
742d2e2d07 | ||
|
|
eb17df87a9 | ||
|
|
b998857839 | ||
|
|
b2e1c09d9f | ||
|
|
80eb097737 | ||
|
|
ab0210218a | ||
|
|
6a59545302 | ||
|
|
f3cf028196 | ||
|
|
cc61e38c44 | ||
|
|
ef73387c3f | ||
|
|
245b677b36 | ||
|
|
3d73ad05e2 | ||
|
|
d3f1decbc1 | ||
|
|
13f136ece5 | ||
|
|
dfab621710 | ||
|
|
391d5320ca | ||
|
|
b771ce2b8f | ||
|
|
f5cfb2499a | ||
|
|
969d2d4a57 | ||
|
|
69afe9c5d3 | ||
|
|
6d745b8c06 | ||
|
|
4d91f7751a | ||
|
|
f42675f9d2 | ||
|
|
b1f1b895c5 | ||
|
|
fbd9bdafc2 | ||
|
|
f2681f2618 | ||
|
|
61972e7c57 | ||
|
|
ce2b1ae6bd | ||
|
|
1f17293186 | ||
|
|
3d9caefb43 | ||
|
|
83375c7434 | ||
|
|
93880013fa | ||
|
|
f2d234ec11 | ||
|
|
e6c55b9044 | ||
|
|
9327dd8d97 | ||
|
|
74d7be4780 | ||
|
|
34a09f838a | ||
|
|
909f58cc7d | ||
|
|
2eaed8f637 | ||
|
|
60ae44dda2 | ||
|
|
09665d4de3 | ||
|
|
2e54e9c591 | ||
|
|
ca0ccf77a1 | ||
|
|
24ff4160c3 | ||
|
|
78c9ef647e | ||
|
|
cf6f49037e | ||
|
|
98f40a5911 | ||
|
|
f6958a7e9b | ||
|
|
e05a97d6e3 | ||
|
|
598289a895 | ||
|
|
73544c5b3f | ||
|
|
9414d2b946 | ||
|
|
e0ffc33e26 | ||
|
|
4546ecee13 | ||
|
|
7e06b2f124 | ||
|
|
2d09c8bac8 | ||
|
|
9e8dd3d285 | ||
|
|
e65d30f2a5 | ||
|
|
497a9f7d99 | ||
|
|
1ed2d4aab5 | ||
|
|
3bde81d967 | ||
|
|
6f30e45057 | ||
|
|
73e2b59ff2 | ||
|
|
c5629a73e2 | ||
|
|
ea51fd9900 | ||
|
|
5989c8653f | ||
|
|
3b3de85fa2 | ||
|
|
b440b215de | ||
|
|
74a9bf8336 | ||
|
|
a1a54dbf7e | ||
|
|
b552c1ce54 | ||
|
|
21ca9e6fea | ||
|
|
d53a745704 | ||
|
|
a36f132bbf | ||
|
|
2ecd7a8162 | ||
|
|
725f9d74e4 | ||
|
|
1d1d5998a8 | ||
|
|
5184fc62bc | ||
|
|
7921cdb4ab | ||
|
|
7dd5d4b746 | ||
|
|
80c206a5e0 | ||
|
|
68907f3685 | ||
|
|
4de266155a | ||
|
|
c8a6506875 | ||
|
|
2c9749bd77 | ||
|
|
9dccaf17b6 | ||
|
|
663ecf03df | ||
|
|
914d93c238 | ||
|
|
dced83ea8a | ||
|
|
38ea10e4ac | ||
|
|
55e0d418e3 | ||
|
|
67303a840f | ||
|
|
1d6b6e8cdd | ||
|
|
a022842f28 | ||
|
|
c4cf92f9e0 | ||
|
|
0898daa4d5 | ||
|
|
8cdc874866 | ||
|
|
941238f4c2 | ||
|
|
66f70f65aa | ||
|
|
d658464ff0 | ||
|
|
e477751d4d | ||
|
|
6b4e16bf2b | ||
|
|
cb84fe98c8 | ||
|
|
b3c6e53217 | ||
|
|
d22922cc9b | ||
|
|
2c38299b99 | ||
|
|
f41b8f164f | ||
|
|
10a6ac81de | ||
|
|
a6ed78aab2 | ||
|
|
dd651efb44 | ||
|
|
5c3185c8a4 | ||
|
|
3ced022980 | ||
|
|
bd7e2a76ef | ||
|
|
8c5df70e86 | ||
|
|
6667576e18 | ||
|
|
a67bde6ddc | ||
|
|
67e690433f | ||
|
|
dab12e581c | ||
|
|
12f053cc88 | ||
|
|
2f1addb3d0 | ||
|
|
631bc45b16 | ||
|
|
372bad379c | ||
|
|
e21e642363 | ||
|
|
296ba5972a | ||
|
|
b1903c20e3 | ||
|
|
c4ce269ceb | ||
|
|
1d47f11bcc | ||
|
|
0d54c810a2 | ||
|
|
b61235313f | ||
|
|
38e0759c8d | ||
|
|
fdc3ee232a | ||
|
|
6fc14f240c | ||
|
|
7a7e40bdc0 | ||
|
|
1bab4ca73b | ||
|
|
45e7191482 | ||
|
|
2261882d4d | ||
|
|
e0cd9ae593 | ||
|
|
d3580a3e95 | ||
|
|
63fa5736c7 | ||
|
|
60129a0c58 | ||
|
|
b839cdd0e3 | ||
|
|
b0d9407839 | ||
|
|
7a4a3cae3b | ||
|
|
fb83ced395 | ||
|
|
e5034fa829 | ||
|
|
118c0c31cd | ||
|
|
9b9a99ccc0 | ||
|
|
86b52c0ade | ||
|
|
ac7fc06c91 | ||
|
|
65e9762904 | ||
|
|
a62ca393bb | ||
|
|
432444bb54 | ||
|
|
fbe3095197 | ||
|
|
bae79d26a2 | ||
|
|
72db4853b1 | ||
|
|
14d49ebf49 | ||
|
|
242dbdf2ca | ||
|
|
4ba7019504 | ||
|
|
7452e5f25b | ||
|
|
85cdf9ce83 | ||
|
|
f318f209aa | ||
|
|
955c4649f5 | ||
|
|
9af1f75d09 | ||
|
|
e37d32940d | ||
|
|
e9645dd93f | ||
|
|
d8c9daee78 | ||
|
|
d9eedaa6dd | ||
|
|
4ea1a79983 | ||
|
|
c00e7c6da5 | ||
|
|
404c4daeb7 | ||
|
|
f487b45e6c | ||
|
|
75008bb731 | ||
|
|
091ffce77e | ||
|
|
0fcb9f94a3 | ||
|
|
e8331d0cda | ||
|
|
23ecb5dd17 | ||
|
|
46ffc00a9b | ||
|
|
3152afc610 | ||
|
|
c45e9108fb | ||
|
|
a27e4f1389 | ||
|
|
b8a192336f | ||
|
|
6a1247c108 | ||
|
|
ece8f5b2f0 | ||
|
|
721125045e | ||
|
|
690af0c2a0 | ||
|
|
4b8f1892fa | ||
|
|
1193b576e1 | ||
|
|
94560f774e | ||
|
|
63076e5312 | ||
|
|
de0e5d19dc | ||
|
|
777a269a39 | ||
|
|
f47fd83c62 | ||
|
|
43a3a8248e | ||
|
|
89e614a106 | ||
|
|
b0f496a9cb | ||
|
|
3d41bd09d0 | ||
|
|
0855485798 | ||
|
|
0481cd8837 | ||
|
|
4cdd5cbea0 | ||
|
|
8dfb2f0376 | ||
|
|
8ec7a3491c | ||
|
|
ca201e79b1 | ||
|
|
a315b0591e | ||
|
|
33002cae22 | ||
|
|
6845c5c238 | ||
|
|
da23ee6ba9 | ||
|
|
59a17f4e90 | ||
|
|
f5887de50a | ||
|
|
4fcf04b6d7 | ||
|
|
146b5622e0 | ||
|
|
dfb4fc123f | ||
|
|
7f16b44b5d | ||
|
|
c6eaa2c9ae | ||
|
|
c393df510e | ||
|
|
a6fa8335c4 | ||
|
|
b042077895 | ||
|
|
784ae26471 | ||
|
|
2cbe7e46c2 | ||
|
|
8dbb97b8a1 | ||
|
|
de1b4119e8 | ||
|
|
cdf76fc39c | ||
|
|
888ad565a3 | ||
|
|
c7e07c0657 | ||
|
|
bd178ed811 | ||
|
|
73920b751e | ||
|
|
e068834c98 | ||
|
|
40ee09903a | ||
|
|
fb4e72791b | ||
|
|
0be779eb72 | ||
|
|
6b444f6b32 | ||
|
|
568ecd2f6f | ||
|
|
3fea9fd251 | ||
|
|
13497e6898 | ||
|
|
c84d8624cc | ||
|
|
3d310828fb | ||
|
|
1ccb289ced | ||
|
|
76df62de23 | ||
|
|
2a7fe5a557 | ||
|
|
d4cb468c37 | ||
|
|
ce01397a9d | ||
|
|
45ddf02c07 | ||
|
|
292c592b71 | ||
|
|
ee6f6b888e | ||
|
|
fd9c509568 | ||
|
|
5b1b29f4d7 | ||
|
|
76824887b3 | ||
|
|
f6861ffaca | ||
|
|
323039c372 | ||
|
|
89af07fffc | ||
|
|
ba4482d847 | ||
|
|
35061a45f0 | ||
|
|
cddfd13876 | ||
|
|
6997be3222 | ||
|
|
4c75c57702 | ||
|
|
889296e843 | ||
|
|
465f1f9f70 | ||
|
|
1a6801b8dc | ||
|
|
fa9c3ec524 | ||
|
|
4124085855 | ||
|
|
5c5c08709e | ||
|
|
9b4be683bb | ||
|
|
e151d35141 | ||
|
|
c304307290 | ||
|
|
567a418565 | ||
|
|
6adaff1c3e | ||
|
|
e8bfa4cff1 | ||
|
|
c71290d3f7 | ||
|
|
5c735ab872 | ||
|
|
ae2aa0ac22 | ||
|
|
32a49881c8 | ||
|
|
3b73fc1e1e | ||
|
|
b29e3de661 | ||
|
|
8bd8d2bfe5 | ||
|
|
a0878a4d58 | ||
|
|
30d5ff4a18 | ||
|
|
b4b5017cbb | ||
|
|
bb3b473ed4 | ||
|
|
20cbc47dd2 | ||
|
|
bd80ab5abd | ||
|
|
7fbe8154b3 | ||
|
|
e4151cb699 | ||
|
|
d3bbddaecd | ||
|
|
0cf4780339 | ||
|
|
6fb9b76ba6 | ||
|
|
f2ed355c28 | ||
|
|
9d95636384 | ||
|
|
00a046d5d6 | ||
|
|
b50cf4d8a2 | ||
|
|
d62e227eb2 | ||
|
|
5accc347b7 | ||
|
|
7d93d7f5be | ||
|
|
133cda7f6b | ||
|
|
5ab58962da | ||
|
|
7f417425e8 | ||
|
|
d9cc58a8be | ||
|
|
718d5bbf63 | ||
|
|
a26a070c25 | ||
|
|
f956caefaf | ||
|
|
385c8ed9b6 | ||
|
|
79c2d535e1 | ||
|
|
8ac13ec9e3 | ||
|
|
e56ebe748c | ||
|
|
7d72a63073 | ||
|
|
8555a1fe29 | ||
|
|
415ba0fc40 | ||
|
|
b4e93ea104 | ||
|
|
d46cdc86df | ||
|
|
dd21904f46 | ||
|
|
0090d1e8f1 | ||
|
|
b402e87f06 | ||
|
|
8c93d5cd8c | ||
|
|
c52e497b3e | ||
|
|
b394070e7a | ||
|
|
628054648a | ||
|
|
e8868946ba | ||
|
|
87898fe269 | ||
|
|
0b2a54d236 | ||
|
|
4c19db188b | ||
|
|
3ed4a0e746 | ||
|
|
de9ecf5539 | ||
|
|
8ac2af9d2b | ||
|
|
3922a6272e | ||
|
|
51591d1e62 | ||
|
|
9f3050ebc9 | ||
|
|
5c78c3a632 | ||
|
|
0b36988881 | ||
|
|
52aedf2721 | ||
|
|
06205faac0 | ||
|
|
af89678db5 | ||
|
|
a126cf68b1 | ||
|
|
386c5d8973 | ||
|
|
d1d0ad47dd | ||
|
|
33e1278333 | ||
|
|
2b854a09d2 | ||
|
|
4567c8042e | ||
|
|
183fb198fb | ||
|
|
f4e301a6b5 | ||
|
|
e670021e04 | ||
|
|
c1098c960b | ||
|
|
6f44d65b13 | ||
|
|
f8b10aa523 | ||
|
|
f865c42f98 | ||
|
|
e3df5d9812 | ||
|
|
f6f9848213 | ||
|
|
e5574256b9 | ||
|
|
648f374869 | ||
|
|
f57b0959f7 | ||
|
|
2de6ccfd7d | ||
|
|
713b273e48 | ||
|
|
7ef337c060 | ||
|
|
b05dadee5e | ||
|
|
8a441e96b9 | ||
|
|
9e623c505c | ||
|
|
835b537aa8 | ||
|
|
d0e6a68abb | ||
|
|
ed79147f9f | ||
|
|
418e2eb89c | ||
|
|
3cf14faf8d | ||
|
|
cf324ee4d4 | ||
|
|
a694f25d3a | ||
|
|
37e3b59a27 | ||
|
|
1609143b12 | ||
|
|
92446525e9 | ||
|
|
23898d12a0 | ||
|
|
aa02f643fb | ||
|
|
7b7eb84333 | ||
|
|
09f787a635 | ||
|
|
56a498ab15 | ||
|
|
d94da16c30 | ||
|
|
1568a58195 | ||
|
|
af607eb157 | ||
|
|
36af34b55d | ||
|
|
a9dd3dd677 | ||
|
|
1fc8caaec9 | ||
|
|
54f79a2ed6 | ||
|
|
81144da0f9 | ||
|
|
51c96258e9 | ||
|
|
eee6b5d4a4 | ||
|
|
520dbe8349 | ||
|
|
88f9923a0a | ||
|
|
ce3aceb3ed | ||
|
|
3ce55cecb7 | ||
|
|
11b3248924 | ||
|
|
57c25c0026 | ||
|
|
b03823dbcd | ||
|
|
9d071b723a | ||
|
|
2e27e84732 | ||
|
|
f79e8fc735 | ||
|
|
d179113543 | ||
|
|
d5ad710835 | ||
|
|
943d64fb42 | ||
|
|
de3a1fa7e1 | ||
|
|
2c65f8d682 | ||
|
|
57946f1909 | ||
|
|
87456ecd7f | ||
|
|
13d333b412 | ||
|
|
4e433eab4e | ||
|
|
b561d9354a | ||
|
|
f69ad552a7 | ||
|
|
c129e8f558 | ||
|
|
89904a2578 | ||
|
|
0a8814343a | ||
|
|
7e6a480e89 | ||
|
|
2084d8c349 | ||
|
|
670d39e8b2 | ||
|
|
953cb59eff | ||
|
|
f9aa09153b | ||
|
|
dcaae608a5 | ||
|
|
f8ec406722 | ||
|
|
687fe27530 | ||
|
|
7e39a87d23 | ||
|
|
08a4ce9f50 | ||
|
|
5fb453d295 | ||
|
|
0602a2d618 | ||
|
|
f2f78dd5a6 | ||
|
|
625fc0f4fd | ||
|
|
8f35e9af4b | ||
|
|
424e857424 | ||
|
|
ec7e6843a6 | ||
|
|
26f9ec3ace | ||
|
|
b67371f580 | ||
|
|
4c89bd3264 | ||
|
|
334e0afd2e | ||
|
|
af3efe0dc9 | ||
|
|
983c0fdbc2 | ||
|
|
55303c1dcc | ||
|
|
e67d281e4b | ||
|
|
a9b53b07c0 | ||
|
|
7c6482e060 | ||
|
|
fc56de9bcc | ||
|
|
c8ffd74a45 | ||
|
|
afec2dd728 | ||
|
|
97c2c5c55b | ||
|
|
a9b3d8e444 | ||
|
|
583d4f2e4d | ||
|
|
5be68f3a7f | ||
|
|
5508f57eba | ||
|
|
9535b09776 | ||
|
|
efa3ddbde6 | ||
|
|
485b404cc7 | ||
|
|
c4c4e63185 | ||
|
|
8d5ca45528 | ||
|
|
a040b89bb0 | ||
|
|
544ccc2979 | ||
|
|
2714de88f9 | ||
|
|
c1fba754a5 | ||
|
|
047042cfbb | ||
|
|
af6f20df69 | ||
|
|
517a402c10 | ||
|
|
1f2e620540 | ||
|
|
6102604a1e | ||
|
|
f66a780dda | ||
|
|
fe08676f8c | ||
|
|
9cd1a6fba2 | ||
|
|
d12acc102f | ||
|
|
ecc221c7f1 | ||
|
|
6d000ec3ee | ||
|
|
e1ac12ab81 | ||
|
|
e2296abafe | ||
|
|
76c3bc2105 | ||
|
|
00e395f7e0 | ||
|
|
fcc3398675 | ||
|
|
1fbf1242ef | ||
|
|
5c94651e3d | ||
|
|
8b6c487b49 | ||
|
|
066badd4e5 | ||
|
|
90ebdabf49 | ||
|
|
326df2337b | ||
|
|
73dec33336 | ||
|
|
717411ac68 | ||
|
|
a2d41505da | ||
|
|
6468cb9ff9 | ||
|
|
ee5424a242 | ||
|
|
de33bd0a50 | ||
|
|
027b732e62 | ||
|
|
772654ef33 | ||
|
|
da76772597 |
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Akascape
|
||||
Copyright (c) 2022 Akash Bora
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
BIN
Python Version/Assets/Icons/Logo.png
Normal file
|
After Width: | Height: | Size: 95 KiB |
BIN
Python Version/Assets/Icons/Program_icon.png
Normal file
|
After Width: | Height: | Size: 372 KiB |
BIN
Python Version/Assets/Icons/right_icon.png
Normal file
|
After Width: | Height: | Size: 4.8 KiB |
BIN
Python Version/Assets/Icons/settings.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
BIN
Python Version/Assets/Icons/video_icon.png
Normal file
|
After Width: | Height: | Size: 5.4 KiB |
BIN
Python Version/Assets/thumbnail_cache/offline_image.png
Normal file
|
After Width: | Height: | Size: 178 KiB |
1
Python Version/Assets/version/VERSIONPY.txt
Normal file
@@ -0,0 +1 @@
|
||||
1.8
|
||||
154
Python Version/DatamoshLib/FFG_effects/basic_modes.py
Normal file
@@ -0,0 +1,154 @@
|
||||
#Author: Akash Bora
|
||||
import os, shutil, subprocess, random, json
|
||||
from pathlib import Path
|
||||
import numpy as np
|
||||
DIRPATH = Path(os.path.dirname(os.path.realpath(__file__)))
|
||||
ffgac=str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffgac"
|
||||
ffedit=str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffedit"
|
||||
|
||||
def library(input_video, output, mode, extract_from="", fluidity=0, size=0, s=0, e=0, vh=0, gop=1000):
|
||||
def get_vectors(input_video):
|
||||
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)
|
||||
subprocess.call(f'"{ffedit}" -i tmp.mpg -f mv:0 -e tmp.json', shell=True)
|
||||
os.remove('tmp.mpg')
|
||||
f = open('tmp.json', 'r')
|
||||
raw_data = json.load(f)
|
||||
f.close()
|
||||
os.remove('tmp.json')
|
||||
frames = raw_data['streams'][0]['frames']
|
||||
vectors = []
|
||||
for frame in frames:
|
||||
try:
|
||||
vectors.append(frame['mv']['forward'])
|
||||
except:
|
||||
vectors.append([])
|
||||
return vectors
|
||||
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}"' +
|
||||
' -vcodec mpeg2video -f rawvideo -y tmp.mpg', shell=True)
|
||||
to_add = '+' if method == 'add' else ''
|
||||
script_path = 'apply_vectors.js'
|
||||
script_contents = '''
|
||||
var vectors = [];
|
||||
var n_frames = 0;
|
||||
function glitch_frame(frame) {
|
||||
let fwd_mvs = frame["mv"]["forward"];
|
||||
if (!fwd_mvs || !vectors[n_frames]) {
|
||||
n_frames++;
|
||||
return;
|
||||
}
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ ) {
|
||||
let row = fwd_mvs[i];
|
||||
for ( let j = 0; j < row.length; j++ ) {
|
||||
let mv = row[j];
|
||||
try {
|
||||
mv[0] ''' + to_add + '''= vectors[n_frames][i][j][0];
|
||||
mv[1] ''' + to_add + '''= vectors[n_frames][i][j][1];
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
n_frames++;
|
||||
}
|
||||
'''
|
||||
with open(script_path, 'w') as f:
|
||||
f.write(script_contents.replace('var vectors = [];', f'var vectors = {json.dumps(vectors)};'))
|
||||
subprocess.call(f'"{ffedit}" -i tmp.mpg -f mv -s "{script_path}" -o "{output_video}"', shell=True)
|
||||
os.remove('apply_vectors.js')
|
||||
os.remove('tmp.mpg')
|
||||
def shuffle(output):
|
||||
if os.path.isdir("cache"):
|
||||
shutil.rmtree("cache")
|
||||
os.mkdir("cache")
|
||||
base=os.path.basename(input_video)
|
||||
fin="cache/"+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}"')
|
||||
os.mkdir("cache/raws")
|
||||
framelist=[]
|
||||
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache/raws/frames_%04d.raw')
|
||||
frames=os.listdir("cache/raws")
|
||||
siz=size
|
||||
framelist.extend(frames)
|
||||
chunked_list=[]
|
||||
chunk_size=siz
|
||||
for i in range(0, len(framelist), chunk_size):
|
||||
chunked_list.append(framelist[i:i+chunk_size])
|
||||
random.shuffle(chunked_list)
|
||||
framelist.clear()
|
||||
for k in frames[0:siz]:
|
||||
framelist.append(k)
|
||||
for i in chunked_list:
|
||||
for j in i:
|
||||
if not j in framelist:
|
||||
framelist.append(j)
|
||||
out_data = b''
|
||||
for fn in framelist:
|
||||
with open("cache/raws/"+fn, 'rb') as fp:
|
||||
out_data += fp.read()
|
||||
with open(output, 'wb+') as fp:
|
||||
fp.write(out_data)
|
||||
fp.close()
|
||||
shutil.rmtree("cache")
|
||||
def rise(output):
|
||||
if os.path.isdir("cache"):
|
||||
shutil.rmtree("cache")
|
||||
os.mkdir("cache")
|
||||
base=os.path.basename(input_video)
|
||||
fin="cache/"+base[:-4]+".mpg"
|
||||
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}"')
|
||||
os.mkdir("cache/raws")
|
||||
framelist=[]
|
||||
subprocess.call(f'"{ffgac}" -i "{fin}" -vcodec copy cache/raws/frames_%04d.raw')
|
||||
kil=e
|
||||
po=s
|
||||
if po==0:
|
||||
po=1
|
||||
frames=os.listdir("cache/raws")
|
||||
for i in frames[po:(po+kil)]:
|
||||
os.remove("cache/raws/"+i)
|
||||
frames.clear()
|
||||
frames=os.listdir("cache/raws")
|
||||
framelist.extend(frames)
|
||||
out_data = b''
|
||||
for fn in framelist:
|
||||
with open("cache/raws/"+fn, 'rb') as fp:
|
||||
out_data += fp.read()
|
||||
with open(output, 'wb') as fp:
|
||||
fp.write(out_data)
|
||||
fp.close()
|
||||
shutil.rmtree("cache")
|
||||
def average(frames):
|
||||
if not frames:
|
||||
return []
|
||||
return np.mean(np.array([x for x in frames if x != []]), axis=0).tolist()
|
||||
def fluid(frames):
|
||||
average_length = fluidity
|
||||
if average_length==1:
|
||||
average_length=2
|
||||
return [average(frames[i + 1 - average_length: i + 1]) for i in range(len(frames))]
|
||||
def movement(frames):
|
||||
for frame in frames:
|
||||
if not frame:
|
||||
continue
|
||||
for row in frame:
|
||||
for col in row:
|
||||
col[vh] = 0
|
||||
return frames
|
||||
if(mode==1):
|
||||
transfer_to=input_video
|
||||
vectors = []
|
||||
if extract_from:
|
||||
vectors = get_vectors(extract_from)
|
||||
if transfer_to == '':
|
||||
with open(output, 'w') as f:
|
||||
json.dump(vectors, f)
|
||||
apply_vectors(vectors, transfer_to, output)
|
||||
elif(mode==2):
|
||||
apply_vectors(movement(get_vectors(input_video)), input_video, output, method='')
|
||||
elif(mode==3):
|
||||
apply_vectors(fluid(get_vectors(input_video)), input_video, output, method='')
|
||||
elif(mode==4):
|
||||
shuffle(output)
|
||||
elif(mode==5):
|
||||
rise(output)
|
||||
15
Python Version/DatamoshLib/FFG_effects/external_script.py
Normal file
@@ -0,0 +1,15 @@
|
||||
#Author: Akash Bora
|
||||
import os, subprocess
|
||||
from pathlib import Path
|
||||
DIRPATH = Path(os.path.dirname(os.path.realpath(__file__)))
|
||||
ffgac=str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffgac"
|
||||
ffedit=str(DIRPATH.parent.parent).replace(os.sep, '/')+"/FFglitch/ffedit"
|
||||
def mosh(input_video, output_video, mode, effect='', scriptfile='', gop=1000):
|
||||
if mode==1:
|
||||
script_path=scriptfile
|
||||
elif mode==2:
|
||||
script_path=str(DIRPATH).replace(os.sep, '/')+"/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}"' +
|
||||
' -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)
|
||||
os.remove('tmp.mpg')
|
||||
75
Python Version/DatamoshLib/FFG_effects/jscripts/Buffer.js
Normal file
@@ -0,0 +1,75 @@
|
||||
// dd_ring_buffer.js
|
||||
// works kinda like an audio delay
|
||||
// stacks the previous n frames into a buffer
|
||||
|
||||
// global variable holding forward motion vectors from previous frames
|
||||
var prev_fwd_mvs = [ ];
|
||||
|
||||
// change these values to use a smaller or greater number of frames to
|
||||
// perform the average of motion vectors
|
||||
|
||||
// try making the delay long enough to overlap an edit in the content ...
|
||||
var delay = 10;
|
||||
// divisor controls "feedback" ... or "feedforward" which ever is a better description ...
|
||||
var feedback = 0.5; // a number between 0.000001 and .... yeah - controls how much of the buffered mv gets into the next pass
|
||||
|
||||
var divisor = 1.0/feedback;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
// update variable holding forward motion vectors from previous
|
||||
// frames. note that we perform a deep copy of the clean motion
|
||||
// vector values before modifying them.
|
||||
let json_str = JSON.stringify(fwd_mvs);
|
||||
let deep_copy = JSON.parse(json_str);
|
||||
// push to the end of array
|
||||
prev_fwd_mvs.push(deep_copy);
|
||||
// drop values from earliest frames to always keep the same tail
|
||||
// length
|
||||
if ( prev_fwd_mvs.length > delay )
|
||||
prev_fwd_mvs = prev_fwd_mvs.slice(1);
|
||||
|
||||
// bail out if we still don't have enough frames
|
||||
if ( prev_fwd_mvs.length != delay )
|
||||
return;
|
||||
|
||||
// replace all motion vectors of current frame with an average
|
||||
// of the motion vectors from the previous 10 frames
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
// loop through all rows
|
||||
let row = fwd_mvs[i];
|
||||
let delay_row = prev_fwd_mvs[0][i];
|
||||
let insert_row = prev_fwd_mvs[delay-1][i];
|
||||
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
let dmv = delay_row[j];
|
||||
let imv = insert_row[j];
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
|
||||
// temp copy of the incoming vectors
|
||||
let x = mv[0];
|
||||
let y = mv[1];
|
||||
// pull their replacements out of the buffer
|
||||
mv[0] = dmv[0];
|
||||
mv[1] = dmv[1];
|
||||
// feedback the 'old' with the 'new' for next time
|
||||
imv[0] = (dmv[0] / divisor) + x;
|
||||
imv[1] = (dmv[1] / divisor) + y;
|
||||
// rinse and repeat
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
71
Python Version/DatamoshLib/FFG_effects/jscripts/Delay.js
Normal file
@@ -0,0 +1,71 @@
|
||||
// dd_delay.js
|
||||
// works kinda like an audio delay
|
||||
// stacks the previous n frames into a buffer
|
||||
|
||||
// global variable holding forward motion vectors from previous frames
|
||||
var prev_fwd_mvs = [ ];
|
||||
|
||||
// change these values to use a smaller or greater number of frames to
|
||||
// perform the average of motion vectors
|
||||
|
||||
// try making the delay long enough to overlap an edit in the content ...
|
||||
var delay = 20;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
// update variable holding forward motion vectors from previous
|
||||
// frames. note that we perform a deep copy of the clean motion
|
||||
// vector values before modifying them.
|
||||
let json_str = JSON.stringify(fwd_mvs);
|
||||
let deep_copy = JSON.parse(json_str);
|
||||
// push to the end of array
|
||||
prev_fwd_mvs.push(deep_copy);
|
||||
// drop values from earliest frames to always keep the same tail
|
||||
// length
|
||||
if ( prev_fwd_mvs.length > delay )
|
||||
prev_fwd_mvs = prev_fwd_mvs.slice(1);
|
||||
|
||||
// bail out if we still don't have enough frames
|
||||
if ( prev_fwd_mvs.length != delay )
|
||||
return;
|
||||
|
||||
// replace all motion vectors of current frame with an average
|
||||
// of the motion vectors from the previous 10 frames
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
// loop through all rows
|
||||
let row = fwd_mvs[i];
|
||||
let delay_row = prev_fwd_mvs[0][i];
|
||||
let insert_row = prev_fwd_mvs[delay-1][i];
|
||||
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
let dmv = delay_row[j];
|
||||
let imv = insert_row[j];
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
|
||||
// temp copy of the incoming vectors
|
||||
let x = mv[0];
|
||||
let y = mv[1];
|
||||
// pull their replacements out of the buffer
|
||||
mv[0] = dmv[0];
|
||||
mv[1] = dmv[1];
|
||||
// feedback the 'old' with the 'new' for next time
|
||||
imv[0] = x;
|
||||
imv[1] = y;
|
||||
// rinse and repeat
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
// dd_RandomDamage(invertRandomN).js
|
||||
// invert x and y component of mv for random number of frames if threshold met for frame
|
||||
|
||||
let threshold = 95;
|
||||
var TRIGGERED = 0;
|
||||
var nFrames = 10;
|
||||
var frameCount = 0;
|
||||
var MAGNITUDE = 20;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
|
||||
var do_or_not = Math.random() * 100;
|
||||
if(do_or_not > threshold){
|
||||
if(TRIGGERED > 0){
|
||||
|
||||
}else{
|
||||
TRIGGERED = 1;
|
||||
frameCount = 0;
|
||||
nFrames = Math.random() * MAGNITUDE;
|
||||
}
|
||||
}
|
||||
// only do the glitch if our random number crosses the threshold
|
||||
if(TRIGGERED > 0 & frameCount <= nFrames){
|
||||
frameCount++;
|
||||
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
var M_H = fwd_mvs.length/2;
|
||||
// clear horizontal element of all motion vectors
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
// loop through all rows
|
||||
let row = fwd_mvs[i];
|
||||
var M_W = row.length/2;
|
||||
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
// STOP XY
|
||||
mv[0] = 0 - mv[0];
|
||||
mv[1] = 0 - mv[1];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
TRIGGERED = 0;
|
||||
}
|
||||
}
|
||||
52
Python Version/DatamoshLib/FFG_effects/jscripts/Mirror.js
Normal file
@@ -0,0 +1,52 @@
|
||||
// dd_mirror_X.js
|
||||
|
||||
// clean buffer :
|
||||
var buffer = [ ];
|
||||
|
||||
var ZOOM = -20;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
// note that we perform a deep copy of the clean motion
|
||||
// vector values before modifying them.
|
||||
let json_str = JSON.stringify(fwd_mvs);
|
||||
let deep_copy = JSON.parse(json_str);
|
||||
// stick em in the buffer
|
||||
buffer = deep_copy;
|
||||
|
||||
var M_H = fwd_mvs.length/2;
|
||||
// VERTICALLY
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
|
||||
// loop through all rows
|
||||
|
||||
let row = fwd_mvs[i];
|
||||
var row2 = buffer[i];
|
||||
//var row2 = fwd_mvs[(fwd_mvs.length-1)-i];
|
||||
|
||||
var M_W = row.length/2;
|
||||
|
||||
// HORIZONTALLY
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
var mv2 = row2[(row.length - 1) - j];
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
//if(i>M_W){
|
||||
mv[0] = 0-mv2[0];
|
||||
mv[1] = mv2[1];
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
67
Python Version/DatamoshLib/FFG_effects/jscripts/Noise.js
Normal file
@@ -0,0 +1,67 @@
|
||||
// dd_MultiplySlowest_50.js
|
||||
// Multiply slowest moving mv's
|
||||
var LARGEST = 0;
|
||||
var SOME_PERCENTAGE = 0.5;
|
||||
var MULTIPLE = 10;
|
||||
|
||||
// global variable holding forward motion vectors from previous frames
|
||||
var prev_fwd_mvs = [ ];
|
||||
|
||||
// change this value to use a smaller or greater number of frmes to average
|
||||
var tail_length = 20;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
LARGEST = 0;
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
// 1st loop - find the fastest mv
|
||||
// this ends-up in LARGEST as the square of the hypotenuse (mv[0]*mv[0]) + (mv[1]*mv[1])
|
||||
let W = fwd_mvs.length;
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
let row = fwd_mvs[i];
|
||||
// rows
|
||||
let H = row.length;
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MEASUREMENT HAPPENS
|
||||
var this_mv = (mv[0] * mv[0])+(mv[1] * mv[1]);
|
||||
if ( this_mv > LARGEST){
|
||||
LARGEST = this_mv;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// then find those mv's which are bigger than SOME_PERCENTAGE of LARGEST
|
||||
// and then replace them with the average mv from the last n frames
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
let row = fwd_mvs[i];
|
||||
// rows
|
||||
let H = row.length;
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
var this_mv = (mv[0] * mv[0])+(mv[1] * mv[1]);
|
||||
if (this_mv < (LARGEST * SOME_PERCENTAGE)){
|
||||
|
||||
mv[0] = mv[0] * MULTIPLE;
|
||||
mv[1] = mv[1] * MULTIPLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Python Version/DatamoshLib/FFG_effects/jscripts/Shear.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// dd_sheer.js
|
||||
|
||||
var ZOOM = -20;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
var M_H = fwd_mvs.length/2;
|
||||
// clear horizontal element of all motion vectors
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
|
||||
// loop through all rows
|
||||
|
||||
let row = fwd_mvs[i];
|
||||
var M_W = row.length/2;
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
//if(i>M_W){
|
||||
mv[0] = mv[0] + ((i - M_W) / 100)*ZOOM;
|
||||
mv[1] = mv[1] + ((j - M_H) / 100)*ZOOM;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
74
Python Version/DatamoshLib/FFG_effects/jscripts/Shift.js
Normal file
@@ -0,0 +1,74 @@
|
||||
// dd_RandomDamage(antiGrav).js
|
||||
// anitgravityify if threshold met for frame
|
||||
|
||||
let threshold = 98;
|
||||
// global variable holding forward motion vectors from previous frames
|
||||
var old_mvs = [ ];
|
||||
// a variable for gravity
|
||||
var rt = 0;
|
||||
var gravity = 0
|
||||
var orig_gravity = 5;
|
||||
var TRIGGERED = 0;
|
||||
var frameCount = 10;
|
||||
var count = 0;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
var do_or_not = Math.random() * 100;
|
||||
// only do the glitch if our random number crosses the threshold
|
||||
if(do_or_not > threshold | TRIGGERED == 1){
|
||||
if(TRIGGERED == 0){
|
||||
gravity = orig_gravity;
|
||||
TRIGGERED = 1;
|
||||
rt = 0;
|
||||
}
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
// buffer first set of vectors. . .
|
||||
if(rt == 0){
|
||||
let json_str = JSON.stringify(fwd_mvs);
|
||||
let deep_copy = JSON.parse(json_str);
|
||||
// push to the end of array
|
||||
old_mvs[0] = (deep_copy);
|
||||
rt = 1;
|
||||
}
|
||||
|
||||
// clear horizontal element of all motion vectors
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
// loop through all rows
|
||||
let row = fwd_mvs[i];
|
||||
let old_row = old_mvs[0][i];
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
let omv = old_row[j];
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
|
||||
mv[0] = mv[0];
|
||||
//if(mv[1] < 0){
|
||||
var nmv = mv[1];
|
||||
mv[1] = omv[1];
|
||||
omv[1] = nmv + omv[1] + gravity;
|
||||
//gravity++;
|
||||
//}else{
|
||||
// mv[1] = mv[1];
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
count++;
|
||||
if(count >= frameCount){
|
||||
TRIGGERED = 0;
|
||||
count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Python Version/DatamoshLib/FFG_effects/jscripts/Sink.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// dd_zero.js
|
||||
// only fuck things up if mv > movement_threshold
|
||||
var movement_threshold = 3;
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
// columns
|
||||
let W = fwd_mvs.length;
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
|
||||
let row = fwd_mvs[i];
|
||||
|
||||
// rows
|
||||
let H = row.length;
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
if ( (mv[0] * mv[0])+(mv[1] * mv[1]) > movement_threshold*movement_threshold){
|
||||
//mv[0] = Math.sin(i/W*Math.PI*2)*mv[0];
|
||||
//mv[1] = Math.cos(j/H*Math.PI*2)*mv[1];
|
||||
mv[0] = 0;//mv[0] * 10;
|
||||
mv[1] = 0;//mv[1] * 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Python Version/DatamoshLib/FFG_effects/jscripts/Slam Zoom.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// dd_slam_zoom_in.js
|
||||
|
||||
var ZOOM = 20;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
var M_H = fwd_mvs.length/2;
|
||||
// clear horizontal element of all motion vectors
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
|
||||
// loop through all rows
|
||||
|
||||
let row = fwd_mvs[i];
|
||||
var M_W = row.length/2;
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
//if(i>M_W){
|
||||
mv[0] = ((M_W - j) / 100)*ZOOM;
|
||||
mv[1] = ((M_H - i) / 100)*ZOOM;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
68
Python Version/DatamoshLib/FFG_effects/jscripts/Slice.js
Normal file
@@ -0,0 +1,68 @@
|
||||
// dd_RandomDamage(progZoom).js
|
||||
// progressive Zoom x and y components of mv if threshold met for frame
|
||||
|
||||
let threshold = 95;
|
||||
|
||||
var ZOOM = 0;
|
||||
var doZOOM = 0;
|
||||
var TRIGGERED = 0;
|
||||
var nFrames = 5;
|
||||
var frameCount = 0;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
|
||||
var do_or_not = Math.random() * 100;
|
||||
if(do_or_not > threshold){
|
||||
if(TRIGGERED > 0){
|
||||
|
||||
}else{
|
||||
TRIGGERED = 1;
|
||||
frameCount = 0;
|
||||
ZOOM = 0;
|
||||
}
|
||||
}
|
||||
// only do the glitch if our random number crosses the threshold
|
||||
if(TRIGGERED > 0 & frameCount <= nFrames){
|
||||
frameCount++;
|
||||
ZOOM+= 10
|
||||
|
||||
var do_dir = Math.random() * 100;
|
||||
if(do_dir > 50){
|
||||
doZOOM = 0 - ZOOM;
|
||||
}else{
|
||||
doZOOM = ZOOM
|
||||
}
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
var M_H = fwd_mvs.length/2;
|
||||
// clear horizontal element of all motion vectors
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
// loop through all rows
|
||||
let row = fwd_mvs[i];
|
||||
var M_W = row.length/2;
|
||||
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
// ZOOM X & Y VECTORS
|
||||
mv[0] = mv[0] + ((M_W - j) / 10)*doZOOM;
|
||||
mv[1] = mv[1] + ((M_H - i) / 10)*doZOOM;
|
||||
|
||||
}
|
||||
}
|
||||
}else{
|
||||
TRIGGERED = 0;
|
||||
}
|
||||
}
|
||||
56
Python Version/DatamoshLib/FFG_effects/jscripts/Stop.js
Normal file
@@ -0,0 +1,56 @@
|
||||
// dd_RandomDamage(stopXY).js
|
||||
// stop x and y component of mv for n framesif threshold met for frame
|
||||
|
||||
let threshold = 95;
|
||||
var TRIGGERED = 0;
|
||||
var nFrames = 10;
|
||||
var frameCount = 0;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
|
||||
var do_or_not = Math.random() * 100;
|
||||
if(do_or_not > threshold){
|
||||
if(TRIGGERED > 0){
|
||||
|
||||
}else{
|
||||
TRIGGERED = 1;
|
||||
frameCount = 0;
|
||||
}
|
||||
}
|
||||
// only do the glitch if our random number crosses the threshold
|
||||
if(TRIGGERED > 0 & frameCount <= nFrames){
|
||||
frameCount++;
|
||||
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
var M_H = fwd_mvs.length/2;
|
||||
// clear horizontal element of all motion vectors
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
// loop through all rows
|
||||
let row = fwd_mvs[i];
|
||||
var M_W = row.length/2;
|
||||
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
// STOP XY
|
||||
mv[0] = 0;
|
||||
mv[1] = 0;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
TRIGGERED = 0;
|
||||
}
|
||||
}
|
||||
29
Python Version/DatamoshLib/FFG_effects/jscripts/Vibrate.js
Normal file
@@ -0,0 +1,29 @@
|
||||
var randomness = 10;
|
||||
var bias = (randomness/2);
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
// clear horizontal element of all motion vectors
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
// loop through all rows
|
||||
let row = fwd_mvs[i];
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
mv[0] = mv[0] + (Math.floor((Math.random() * randomness) -bias));
|
||||
mv[1] = mv[1] + (Math.floor((Math.random() * randomness) -bias));
|
||||
}
|
||||
}
|
||||
}
|
||||
38
Python Version/DatamoshLib/FFG_effects/jscripts/Zoom.js
Normal file
@@ -0,0 +1,38 @@
|
||||
// dd_zoom_in.js
|
||||
|
||||
var ZOOM = 20;
|
||||
|
||||
function glitch_frame(frame)
|
||||
{
|
||||
// bail out if we have no motion vectors
|
||||
let mvs = frame["mv"];
|
||||
if ( !mvs )
|
||||
return;
|
||||
// bail out if we have no forward motion vectors
|
||||
let fwd_mvs = mvs["forward"];
|
||||
if ( !fwd_mvs )
|
||||
return;
|
||||
|
||||
var M_H = fwd_mvs.length/2;
|
||||
// clear horizontal element of all motion vectors
|
||||
for ( let i = 0; i < fwd_mvs.length; i++ )
|
||||
{
|
||||
|
||||
// loop through all rows
|
||||
|
||||
let row = fwd_mvs[i];
|
||||
var M_W = row.length/2;
|
||||
|
||||
for ( let j = 0; j < row.length; j++ )
|
||||
{
|
||||
// loop through all macroblocks
|
||||
let mv = row[j];
|
||||
|
||||
// THIS IS WHERE THE MAGIC HAPPENS
|
||||
//if(i>M_W){
|
||||
mv[0] = mv[0] + ((M_W - j) / 100)*ZOOM;
|
||||
mv[1] = mv[1] + ((M_H - i) / 100)*ZOOM;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Python Version/DatamoshLib/Original/classic.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#Author: Akash Bora
|
||||
import subprocess
|
||||
def Datamosh(filename, outf, s, e, p, fps=30):
|
||||
END_FRAME_HEX = b'00dc'
|
||||
I_FRAME_HEX = b'\x00\x01\xb0'
|
||||
def main(filename, effect_sec_list, p_frames_mult):
|
||||
mosh(effect_sec_list, p_frames_mult)
|
||||
def mosh(effect_sec_list, p_frames_mult):
|
||||
with open(filename, 'rb') as in_file, open(outf, 'wb') as out_file:
|
||||
frames = split_file(in_file, END_FRAME_HEX)
|
||||
for index, frame in enumerate(frames):
|
||||
if not is_need_effect_here(index / fps, effect_sec_list):
|
||||
out_file.write(frame + END_FRAME_HEX)
|
||||
continue
|
||||
if not is_iframe(frame):
|
||||
out_file.write((frame + END_FRAME_HEX) * p_frames_mult)
|
||||
def split_file(fp, marker, blocksize=4096):
|
||||
buffer = b''
|
||||
for block in iter(lambda: fp.read(blocksize), b''):
|
||||
buffer += block
|
||||
while True:
|
||||
markerpos = buffer.find(marker)
|
||||
if markerpos == -1:
|
||||
break
|
||||
yield buffer[:markerpos]
|
||||
buffer = buffer[markerpos + len(marker):]
|
||||
yield buffer
|
||||
def is_need_effect_here(curr_sec, effect_sec_list):
|
||||
return any(start < curr_sec < end for start, end in effect_sec_list)
|
||||
def is_iframe(frame):
|
||||
return frame[5:8] == I_FRAME_HEX
|
||||
start=s
|
||||
end=e
|
||||
pf=p
|
||||
main(filename,[(start,end)],pf)
|
||||
64
Python Version/DatamoshLib/Original/pymodes.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#Author: Akash Bora
|
||||
from pymosh import Index
|
||||
from pymosh.codec.mpeg4 import is_iframe
|
||||
from itertools import islice
|
||||
class library():
|
||||
def glide(interval, filename, outfile):
|
||||
f = Index.from_file(filename)
|
||||
buf = [None]
|
||||
def process_frame(frame):
|
||||
if buf[0] == None or not is_iframe(frame):
|
||||
buf[0] = frame
|
||||
else:
|
||||
frame = buf[0]
|
||||
return frame
|
||||
for stream in f.video:
|
||||
newstream = []
|
||||
newstream.append(stream[0])
|
||||
ix = 0
|
||||
jx = 0
|
||||
for i in stream[1:]:
|
||||
ix += 1
|
||||
jx += 1
|
||||
if ix < interval:
|
||||
newstream.append(process_frame(stream[jx]))
|
||||
else:
|
||||
newstream.append(newstream[-1])
|
||||
if ix > interval * 2:
|
||||
ix = 0
|
||||
stream.replace(newstream)
|
||||
f.rebuild()
|
||||
with open(outfile, 'wb') as out:
|
||||
f.write(out)
|
||||
|
||||
def avi_sort(filename, outfile, mode, rev):
|
||||
f = Index.from_file(filename)
|
||||
for stream in f.video:
|
||||
if mode==0:
|
||||
sorted_stream = sorted(stream, key=len, reverse=rev)
|
||||
else:
|
||||
sorted_stream = sorted(stream, key=lambda s: s[len(s)-6], reverse=rev)
|
||||
stream.replace(sorted_stream)
|
||||
f.rebuild()
|
||||
with open(outfile, 'wb') as out:
|
||||
f.write(out)
|
||||
|
||||
def process_streams(in_filename, out_filename, mid=''):
|
||||
def echo(stream, midpoint):
|
||||
all_frames = list(stream)
|
||||
pframes = [f for f in all_frames if not is_iframe(f)]
|
||||
midpoint_idx = int(len(all_frames)*midpoint)
|
||||
frames = all_frames[:midpoint_idx]
|
||||
while len(frames) < len(all_frames):
|
||||
frames += pframes[:(len(all_frames) - len(frames))]
|
||||
return frames
|
||||
mode=echo
|
||||
f = Index.from_file(in_filename)
|
||||
for stream in f.video:
|
||||
midpoint=mid
|
||||
drifted = list(mode(stream, midpoint))
|
||||
stream.replace(drifted)
|
||||
f.rebuild()
|
||||
with open(out_filename, 'wb') as out:
|
||||
f.write(out)
|
||||
|
||||
43
Python Version/DatamoshLib/Original/repeat.py
Normal file
@@ -0,0 +1,43 @@
|
||||
#Author: Akash Bora
|
||||
def Datamosh(filename,outfile,s,e,p,fps):
|
||||
def write_frame(frame):
|
||||
out_file.write(frame_start + frame)
|
||||
def mosh_delta_repeat(n_repeat):
|
||||
if n_repeat=="1":
|
||||
n_repeat=2
|
||||
repeat_frames = []
|
||||
repeat_index = 0
|
||||
for index, frame in enumerate(frames):
|
||||
if (frame[5:8] != iframe and frame[5:8] != pframe) or not start_frame <= index < end_frame:
|
||||
write_frame(frame)
|
||||
continue
|
||||
if len(repeat_frames) < n_repeat and frame[5:8] != iframe:
|
||||
repeat_frames.append(frame)
|
||||
write_frame(frame)
|
||||
elif len(repeat_frames) == n_repeat:
|
||||
write_frame(repeat_frames[repeat_index])
|
||||
repeat_index = (repeat_index + 1) % n_repeat
|
||||
else:
|
||||
write_frame(frame)
|
||||
start_frame = s
|
||||
end_frame = e
|
||||
if end_frame==1:
|
||||
end_frame=1000
|
||||
input_avi = filename
|
||||
delta = p
|
||||
in_file = open(input_avi, 'rb')
|
||||
output_avi= outfile
|
||||
in_file_bytes = in_file.read()
|
||||
out_file = open(output_avi, 'wb')
|
||||
frame_start = bytes.fromhex('30306463')
|
||||
frames = in_file_bytes.split(frame_start)
|
||||
out_file.write(frames[0])
|
||||
frames = frames[1:]
|
||||
iframe = bytes.fromhex('0001B0')
|
||||
pframe = bytes.fromhex('0001B6')
|
||||
n_video_frames = len([frame for frame in frames if frame[5:8] == iframe or frame[5:8] == pframe])
|
||||
if end_frame < 0:
|
||||
end_frame = n_video_frames
|
||||
mosh_delta_repeat(delta)
|
||||
in_file.close()
|
||||
out_file.close()
|
||||
21
Python Version/DatamoshLib/Tomato/LICENSE.txt
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Kaspar RAVEL
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
234
Python Version/DatamoshLib/Tomato/tomato.py
Normal file
@@ -0,0 +1,234 @@
|
||||
#Original Author: Kasper Ravel
|
||||
#Modified by: Akash Bora
|
||||
import os, re, random, struct
|
||||
from itertools import chain
|
||||
from itertools import repeat
|
||||
def mosh(infile, outfile, m, c, n, a, f, k):
|
||||
print (" _ _ ")
|
||||
print ("| | | | ")
|
||||
print ("| |_ ___ _ __ ___ __ _| |_ ___ ")
|
||||
print ("| __/ _ \| '_ ` _ \ / _` | __/ _ \ ")
|
||||
print ("| || (_) | | | | | | (_| | || (_) |")
|
||||
print (" \__\___/|_| |_| |_|\__,_|\__\___/ ")
|
||||
print ("Tomato Automosh v2.0")
|
||||
print ("\\\\ Audio Video Interleave breaker")
|
||||
print (" ")
|
||||
print ("glitch tool made with love for the glitch art community <3")
|
||||
print ("___________________________________")
|
||||
|
||||
filein = infile
|
||||
mode = m
|
||||
countframes = c
|
||||
positframes = n
|
||||
audio = a
|
||||
firstframe = f
|
||||
kill = k
|
||||
if filein is None or os.path.exists(filein) == False:
|
||||
print("> step 0/5: valid input file required!")
|
||||
print("use -h to see help")
|
||||
exit()
|
||||
|
||||
|
||||
#define temp directory and files
|
||||
temp_nb = random.randint(10000, 99999)
|
||||
temp_dir = "temp-" + str(temp_nb)
|
||||
temp_hdrl = temp_dir +"\\hdrl.bin"
|
||||
temp_movi = temp_dir +"\\movi.bin"
|
||||
temp_idx1 = temp_dir +"\\idx1.bin"
|
||||
|
||||
os.mkdir(temp_dir)
|
||||
|
||||
#Define constrain function for jiggle :3
|
||||
def constrain(val, min_val, max_val):
|
||||
return min(max_val, max(min_val, val))
|
||||
|
||||
######################################
|
||||
### STREAM FILE INTO WORK DIR BINS ###
|
||||
######################################
|
||||
|
||||
print("> step 1/5 : streaming into binary files")
|
||||
|
||||
def bstream_until_marker(bfilein, bfileout, marker=0, startpos=0):
|
||||
chunk = 1024
|
||||
filesize = os.path.getsize(bfilein)
|
||||
if marker :
|
||||
marker = str.encode(marker)
|
||||
|
||||
with open(bfilein,'rb') as rd:
|
||||
with open(bfileout,'ab') as wr:
|
||||
for pos in range(startpos, filesize, chunk):
|
||||
rd.seek(pos)
|
||||
buffer = rd.read(chunk)
|
||||
|
||||
if marker:
|
||||
if buffer.find(marker) > 0 :
|
||||
marker_pos = re.search(marker, buffer).start() # position is relative to buffer glitchedframes
|
||||
marker_pos = marker_pos + pos # position should be absolute now
|
||||
split = buffer.split(marker, 1)
|
||||
wr.write(split[0])
|
||||
return marker_pos
|
||||
else:
|
||||
wr.write(buffer)
|
||||
else:
|
||||
wr.write(buffer)
|
||||
|
||||
#make 3 files, 1 for each chunk
|
||||
movi_marker_pos = bstream_until_marker(filein, temp_hdrl, "movi")
|
||||
idx1_marker_pos = bstream_until_marker(filein, temp_movi, "idx1", movi_marker_pos)
|
||||
bstream_until_marker(filein, temp_idx1, 0, idx1_marker_pos)
|
||||
|
||||
####################################
|
||||
### FUN STUFF WITH VIDEO CONTENT ###
|
||||
####################################
|
||||
|
||||
print("> step 2/5 : constructing frame index")
|
||||
|
||||
with open(temp_movi,'rb') as rd:
|
||||
chunk = 1024
|
||||
filesize = os.path.getsize(temp_movi)
|
||||
frame_table = []
|
||||
|
||||
for pos in range(0, filesize, chunk):
|
||||
rd.seek(pos)
|
||||
buffer = rd.read(chunk)
|
||||
|
||||
#build first list with all adresses
|
||||
for m in (re.finditer(b'\x30\x31\x77\x62', buffer)): # find iframes
|
||||
if audio : frame_table.append([m.start() + pos, 'sound'])
|
||||
for m in (re.finditer(b'\x30\x30\x64\x63', buffer)): # find b frames
|
||||
frame_table.append([m.start() + pos, 'video'])
|
||||
|
||||
#then remember to sort the list
|
||||
frame_table.sort(key=lambda tup: tup[0])
|
||||
|
||||
l = []
|
||||
l.append([0,0, 'void'])
|
||||
max_frame_size = 0
|
||||
|
||||
#build tuples for each frame index with frame sizes
|
||||
for n in range(len(frame_table)):
|
||||
if n + 1 < len(frame_table):
|
||||
frame_size = frame_table[n + 1][0] - frame_table[n][0]
|
||||
else:
|
||||
frame_size = filesize - frame_table[n][0]
|
||||
max_frame_size = max(max_frame_size, frame_size)
|
||||
l.append([frame_table[n][0],frame_size, frame_table[n][1]])
|
||||
|
||||
|
||||
########################
|
||||
### TIME FOR SOME FX ###
|
||||
########################
|
||||
|
||||
# variables that make shit work
|
||||
clean = []
|
||||
final = []
|
||||
|
||||
# keep first video frame or not
|
||||
if firstframe:
|
||||
for x in l:
|
||||
if x[2] == 'video':
|
||||
clean.append(x)
|
||||
break
|
||||
|
||||
# clean the list by killing "big" frames
|
||||
for x in l:
|
||||
if x[1] <= (max_frame_size * kill) :
|
||||
clean.append(x)
|
||||
# FX modes
|
||||
if mode == "void":
|
||||
print('> step 3/5 : mode void')
|
||||
final = clean
|
||||
|
||||
if mode == "random":
|
||||
print('> step 3/5 : mode random')
|
||||
final = random.sample(clean,len(clean))
|
||||
|
||||
if mode == "reverse":
|
||||
print('> step 3/5 : mode reverse')
|
||||
final = sum(zip(clean[::-1], clean[:-1]), ())
|
||||
|
||||
if mode == "invert":
|
||||
print('> step 3/5 : mode invert')
|
||||
final = sum(zip(clean[1::2], clean[::2]), ())
|
||||
|
||||
if mode == 'bloom':
|
||||
print('> step 3/5 : mode bloom')
|
||||
repeat = int(countframes)
|
||||
frame = int(positframes)
|
||||
## split list
|
||||
lista = clean[:frame]
|
||||
listb = clean[frame:]
|
||||
## rejoin list with bloom
|
||||
final = lista + ([clean[frame]]*repeat) + listb
|
||||
|
||||
if mode == 'pulse':
|
||||
print('> step 3/5 : mode pulse')
|
||||
pulselen = int(countframes)
|
||||
pulseryt = int(positframes)
|
||||
j = 0
|
||||
for x in clean:
|
||||
i = 0
|
||||
if(j % pulselen == 0):
|
||||
while i < pulselen :
|
||||
final.append(x)
|
||||
i = i + 1
|
||||
else:
|
||||
final.append(x)
|
||||
j = j + 1
|
||||
|
||||
if mode == "jiggle":
|
||||
print('> step 3/5 : mode jiggle')
|
||||
#print('*needs debugging lol help thx*') # didn't pandy's branch fix this?
|
||||
amount = int(positframes)
|
||||
final = [clean[constrain(x+int(random.gauss(0,amount)),0,len(clean)-1)] for x in range(0,len(clean))]
|
||||
|
||||
if mode == "overlap":
|
||||
print('> step 3/5 : mode overlap')
|
||||
pulselen = int(countframes)
|
||||
pulseryt = int(positframes)
|
||||
|
||||
clean = [clean[i:i+pulselen] for i in range(0,len(clean),pulseryt)]
|
||||
final = [item for sublist in clean for item in sublist]
|
||||
|
||||
if mode == 'exponential':#Ask Kasper to add these modes (Note by Akash)
|
||||
print('> step 3/5 : mode exponential')
|
||||
print('sorry, currently not implemented. using void..')
|
||||
|
||||
if mode == 'swap':
|
||||
print('> step 3/5 : mode swap')
|
||||
print('sorry, currently not implemented. using void..')
|
||||
|
||||
|
||||
####################################
|
||||
### PUT VIDEO FILE BACK TOGETHER ###
|
||||
####################################
|
||||
|
||||
print("> step 4/5 : putting things back together")
|
||||
|
||||
#name new file
|
||||
fileout = outfile
|
||||
|
||||
#delete old file
|
||||
if os.path.exists(fileout):
|
||||
os.remove(fileout)
|
||||
|
||||
bstream_until_marker(temp_hdrl, fileout)
|
||||
|
||||
with open(temp_movi,'rb') as rd:
|
||||
filesize = os.path.getsize(temp_movi)
|
||||
with open(fileout,'ab') as wr:
|
||||
wr.write(struct.pack('<4s', b'movi'))
|
||||
for x in final:
|
||||
if x[0] != 0 and x[1] != 0:
|
||||
rd.seek(x[0])
|
||||
wr.write(rd.read(x[1]))
|
||||
|
||||
bstream_until_marker(temp_idx1, fileout)
|
||||
|
||||
#remove unnecessary temporary files and folders
|
||||
os.remove(temp_hdrl)
|
||||
os.remove(temp_movi)
|
||||
os.remove(temp_idx1)
|
||||
os.rmdir(temp_dir)
|
||||
|
||||
print("> step 5/5 : done - final idx size : " + str(len(final)))
|
||||
0
Python Version/FFglitch/FFglitch goes here
Normal file
@@ -1,6 +0,0 @@
|
||||
#Read this to use the python version.
|
||||
<br>This version is comparitively lower in size and works the same inside python environment. To use this version, just download the zip file and extract this folder and then double click on the Datamosher Prp.py to open the program, then use the software as describes in the Readme.md or click the "i" button inside the software.
|
||||
<br>Note that you must have the required modules installed. Most of the modules that are used are installed by default, but only one module you need to install separately is Imageio.
|
||||
<br>To install that module, open CMD or other terminal and type "pip install Imageio" and "pip install Imageio-ffmpeg, then it will be installed and you can open Datamosher Pro.py
|
||||
<br>Do not delete or move any assets that are linked with the main file or else it will show error.
|
||||
<br>So, this is all about the python version, you can now Datamosh your videos!
|
||||
127
Python Version/Setup.py
Normal file
@@ -0,0 +1,127 @@
|
||||
#Automatic Setup for Datamosher-Pro
|
||||
#Author: Akash Bora
|
||||
|
||||
#Importing some built in modules
|
||||
import subprocess
|
||||
import pkg_resources
|
||||
import sys
|
||||
import time
|
||||
import os
|
||||
import shutil
|
||||
from zipfile import ZipFile
|
||||
|
||||
DIRPATH = os.path.dirname(os.path.realpath(__file__))
|
||||
#Checking the required folders
|
||||
folders= ["Assets","FFglitch","DatamoshLib","pymosh"]
|
||||
missingfolder=[]
|
||||
for i in folders:
|
||||
if not os.path.exists(i):
|
||||
missingfolder.append(i)
|
||||
if missingfolder:
|
||||
print("These folder(s) not available: "+str(missingfolder))
|
||||
print("Download them from the repository properly")
|
||||
sys.exit()
|
||||
else:
|
||||
print("All folders available!")
|
||||
|
||||
#Checking required modules
|
||||
required = {'imageio', 'imageio-ffmpeg', 'numpy', 'customtkinter', 'pillow', 'rangeslider', 'requests'}
|
||||
installed = {pkg.key for pkg in pkg_resources.working_set}
|
||||
missing = required - installed
|
||||
missingset=[*missing,]
|
||||
|
||||
#Download the modules if not installed
|
||||
if missing:
|
||||
res=input("Some modules are not installed \n do you want to download and install them? (Y/N): ")
|
||||
while not ((res=="Y") or (res=="y") or (res=="N") or (res=="n")):
|
||||
print("Please choose a valid option!")
|
||||
res=input("Some modules are not installed \n do you want to download and install them? (Y/N): ")
|
||||
if res=="Y" or res=="y":
|
||||
try:
|
||||
print("Installing modules...")
|
||||
for x in range(len(missingset)):
|
||||
y=missingset[x]
|
||||
if sys.platform.startswith("win"):
|
||||
subprocess.call('python -m pip install '+y, shell=True)
|
||||
else:
|
||||
subprocess.call('python3 -m pip install '+y, shell=True)
|
||||
except:
|
||||
print("Unable to download! \nThis are the required ones: "+str(required)+"\nUse 'pip install module_name' to download the modules one by one")
|
||||
time.sleep(3)
|
||||
sys.exit()
|
||||
elif res=="N" or res=="n":
|
||||
print("Without the modules you can't use this program. Please install them first! \nThis are the required one: "+str(required)
|
||||
+"\nUse 'pip install module_name' to download modules one by one")
|
||||
time.sleep(3)
|
||||
sys.exit()
|
||||
else:
|
||||
print("All modules installed!")
|
||||
|
||||
#Check FFglitch Status
|
||||
def checkffglitch():
|
||||
print("Checking FFglitch:")
|
||||
print("Running ffgac...")
|
||||
ffgac=str(DIRPATH).replace(os.sep, '/')+"/FFglitch/ffgac"
|
||||
ffedit=str(DIRPATH).replace(os.sep, '/')+"/FFglitch/ffedit"
|
||||
try:
|
||||
subprocess.Popen(f'"{ffgac}" -version', shell=True)
|
||||
except:
|
||||
print("permission denied! Please give permission to ffgac to execute.")
|
||||
time.sleep(1)
|
||||
print("Running ffedit...")
|
||||
try:
|
||||
subprocess.Popen(f'"{ffedit}" -version', shell=True)
|
||||
except:
|
||||
print("permission denied! Please give permission to ffedit to execute.")
|
||||
time.sleep(1)
|
||||
print("Done...")
|
||||
|
||||
#Download ffglitch if not available
|
||||
if (os.path.exists("FFglitch/ffgac") or os.path.exists("FFglitch/ffgac.exe")) and (os.path.exists("FFglitch/ffedit") or os.path.exists("FFglitch/ffedit.exe")):
|
||||
checkffglitch()
|
||||
else:
|
||||
print("ffgac/ffedit not found inside ffglitch folder, you cannot run the ffglitch modes without these programs")
|
||||
res2=input("Do you want to download ffglitch now? (Y/N): ")
|
||||
while not ((res2=="Y") or (res2=="y") or (res2=="N") or (res2=="n")):
|
||||
print("Please choose a valid option!")
|
||||
res2=input("Do you want to download ffglitch now? (Y/N): ")
|
||||
if res2=="Y" or res2=="y":
|
||||
print("Downloading FFglitch...(size: approx 17MB)")
|
||||
if sys.platform.startswith("win"): #download ffglitch for windows
|
||||
URL = "https://github.com/Akascape/FFglitch-0.9.3-executables/releases/download/zip-packages/ffglitch-0.9.3-win64.zip"
|
||||
elif sys.platform.startswith("linux"): #download ffglitch for linux
|
||||
URL = "https://github.com/Akascape/FFglitch-0.9.3-executables/releases/download/zip-packages/ffglitch-0.9.3-linux64.zip"
|
||||
else: #download ffglitch for mac
|
||||
URL = "https://github.com/Akascape/FFglitch-0.9.3-executables/releases/download/zip-packages/ffglitch-0.9.3-mac64.zip"
|
||||
try:
|
||||
try:
|
||||
import requests
|
||||
response = requests.get(URL)
|
||||
open("FFglitch//ffglitch.zip", "wb").write(response.content)
|
||||
except:
|
||||
print("Unable to download ffglitch from site! Check your connection or download it manually from https://github.com/Akascape/FFglitch-0.9.3-executables \nand paste the files (ffgac and ffedit) inside FFglitch folder.")
|
||||
time.sleep(3)
|
||||
sys.exit()
|
||||
time.sleep(1)
|
||||
print("Exctracting the files...")
|
||||
try:
|
||||
with ZipFile('FFglitch/ffglitch.zip', 'r') as zip:
|
||||
zip.extractall('FFglitch/')
|
||||
except:
|
||||
print("Failed to extract ffglitch.zip, please extract it manually in the FFglitch folder.")
|
||||
time.sleep(3)
|
||||
sys.exit()
|
||||
if os.path.exists("FFglitch/ffgac") or os.path.exists("FFglitch/ffgac.exe"):
|
||||
os.remove("FFglitch//ffglitch.zip")
|
||||
time.sleep(1)
|
||||
checkffglitch()
|
||||
print("FFglitch setup complete!")
|
||||
except:
|
||||
print("Something went wrong!")
|
||||
elif res2=="N" or res2=="n":
|
||||
print("ffglitch modes cannot run without ffgac and ffedit, download them manually and paste them inside the FFglitch folder.")
|
||||
|
||||
#Everything done!
|
||||
print("Setup Complete!")
|
||||
time.sleep(5)
|
||||
sys.exit()
|
||||
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 213 KiB |
|
Before Width: | Height: | Size: 2.5 KiB |
7
Python Version/pymosh/LICENSE.txt
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2011 - 2014 Joe Friedl
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
27
Python Version/pymosh/__init__.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from .container import avi
|
||||
|
||||
__all__ = ['Index']
|
||||
|
||||
|
||||
class Index(object):
|
||||
"""Index is an index of video frame data."""
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def from_file(filename: str):
|
||||
instance = Index()
|
||||
instance.filename = filename
|
||||
instance.index = None
|
||||
|
||||
# Assume AVI for now
|
||||
instance.index = avi.AVIFile.from_file(filename)
|
||||
|
||||
return instance
|
||||
|
||||
def __getattr__(self, index):
|
||||
return getattr(self.index, index)
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.index)
|
||||
0
Python Version/pymosh/codec/__init__.py
Normal file
6
Python Version/pymosh/codec/mpeg4.py
Normal file
@@ -0,0 +1,6 @@
|
||||
IFRAME_HEADER = b'\x00\x00\x01\xb0'
|
||||
|
||||
|
||||
def is_iframe(frame):
|
||||
"""Determine whether frame is an I frame."""
|
||||
return frame[:4] == IFRAME_HEADER
|
||||
0
Python Version/pymosh/container/__init__.py
Normal file
124
Python Version/pymosh/container/avi.py
Normal file
@@ -0,0 +1,124 @@
|
||||
import struct
|
||||
|
||||
from pymosh.codec.mpeg4 import is_iframe
|
||||
|
||||
from . import riff
|
||||
|
||||
|
||||
class AVIFile(object):
|
||||
"""A wrapper for AVI files."""
|
||||
|
||||
def __init__(self):
|
||||
self.riff = riff.RiffIndex()
|
||||
self.streams = []
|
||||
self.frame_order = []
|
||||
|
||||
@staticmethod
|
||||
def from_file(filename: str):
|
||||
instance = AVIFile()
|
||||
|
||||
instance.riff = riff.RiffIndex.from_file(filename=filename)
|
||||
|
||||
header = instance.riff.find(b'LIST', b'hdrl')
|
||||
# Get stream info
|
||||
stream_lists = header.find_all(b'LIST', b'strl')
|
||||
for l in stream_lists:
|
||||
strh = l.find(b'strh')
|
||||
data = strh.data
|
||||
fccType, = struct.unpack(b'4s', data[:4])
|
||||
stream = Stream(len(instance.streams), fccType)
|
||||
instance.streams.append(stream)
|
||||
|
||||
instance.split_streams()
|
||||
|
||||
return instance
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.streams)
|
||||
|
||||
def add_frame(self, chunk):
|
||||
stream_num = int(chunk.header[:2])
|
||||
if stream_num < len(self.streams):
|
||||
self.frame_order.append(
|
||||
(stream_num, len(self.streams[stream_num])))
|
||||
self.streams[stream_num].add_frame(chunk)
|
||||
|
||||
def split_streams(self):
|
||||
movi = self.riff.find(b'LIST', b'movi')
|
||||
for chunk in movi:
|
||||
self.add_frame(chunk)
|
||||
|
||||
def combine_streams(self):
|
||||
chunks = []
|
||||
for frame_record in self.frame_order:
|
||||
stream_num, frame_num = frame_record
|
||||
stream = self.streams[stream_num]
|
||||
frame = stream[frame_num]
|
||||
chunks.append(frame)
|
||||
return chunks
|
||||
|
||||
def _video(self):
|
||||
return filter(lambda stream: stream.type == b'vids', self.streams)
|
||||
video = property(_video)
|
||||
|
||||
def _audio(self):
|
||||
return filter(lambda stream: stream.type == b'auds', self.streams)
|
||||
audio = property(_audio)
|
||||
|
||||
def rebuild(self):
|
||||
"""Rebuild RIFF tree and index from streams."""
|
||||
movi = self.riff.find(b'LIST', b'movi')
|
||||
movi.chunks = self.combine_streams()
|
||||
self.rebuild_index()
|
||||
|
||||
def rebuild_index(self):
|
||||
old_index = self.riff.find(b'idx1')
|
||||
movi = self.riff.find(b'LIST', b'movi')
|
||||
data = b''
|
||||
offset = 0
|
||||
flags = {
|
||||
'base': 0x00000000,
|
||||
'keyframe': 0x00000010,
|
||||
}
|
||||
for chunk in movi:
|
||||
length = len(chunk)
|
||||
frame_flags = flags['base']
|
||||
# If it's a video keyframe or audio frame, use keyframe flag
|
||||
if (chunk.header[2] == b'd' and is_iframe(chunk)) or (chunk.header[2] == b'w'):
|
||||
frame_flags |= flags['keyframe']
|
||||
data += struct.pack(b'<4sIII', chunk.header, frame_flags, offset,
|
||||
length+8)
|
||||
offset += length + 8 + (length % 2)
|
||||
new_index = riff.RiffDataChunk(b'idx1', data)
|
||||
self.riff.find(b'RIFF').replace(old_index, new_index)
|
||||
|
||||
def write(self, fh):
|
||||
self.riff.write(fh)
|
||||
|
||||
|
||||
class Stream(object):
|
||||
def __init__(self, num, stream_type):
|
||||
self.num = int(num)
|
||||
self.type = stream_type
|
||||
self.chunks = []
|
||||
|
||||
def add_frame(self, chunk):
|
||||
self.chunks.append(chunk)
|
||||
|
||||
def __getitem__(self, index):
|
||||
return self.chunks.__getitem__(index)
|
||||
|
||||
def __iter__(self):
|
||||
return self.chunks.__iter__()
|
||||
|
||||
def __len__(self):
|
||||
return len(self.chunks)
|
||||
|
||||
def append(self, *args):
|
||||
return self.chunks.append(*args)
|
||||
|
||||
def extend(self, *args):
|
||||
return self.chunks.extend(*args)
|
||||
|
||||
def replace(self, chunks):
|
||||
self.chunks = chunks
|
||||
263
Python Version/pymosh/container/riff.py
Normal file
@@ -0,0 +1,263 @@
|
||||
import os
|
||||
import struct
|
||||
from io import IOBase
|
||||
|
||||
list_headers = (b'RIFF', b'LIST')
|
||||
|
||||
|
||||
class UnexpectedEOF(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class RiffIndexChunk(object):
|
||||
def __init__(self, fh, header, length, position):
|
||||
self.file = fh
|
||||
self.header = header
|
||||
self.length = int(length)
|
||||
self.position = position
|
||||
|
||||
def __str__(self):
|
||||
return str(self.bytes())
|
||||
|
||||
def bytes(self) -> bytes:
|
||||
return self.header + struct.pack('<I', self.length) + self.data
|
||||
|
||||
def __len__(self):
|
||||
return self.length
|
||||
|
||||
def __getslice__(self, start, end):
|
||||
if start is None:
|
||||
start = 0
|
||||
if end is None:
|
||||
end = self.length
|
||||
|
||||
current = self.file.tell()
|
||||
self.file.seek(self.position+start)
|
||||
if start < end and start <= self.length:
|
||||
if end > self.length:
|
||||
end = self.length
|
||||
data = self.file.read(end-start)
|
||||
self.file.seek(current)
|
||||
return data
|
||||
else:
|
||||
return ''
|
||||
|
||||
def __getitem__(self, index):
|
||||
if isinstance(index, slice):
|
||||
return self.__getslice__(index.start, index.stop)
|
||||
return self[index:index+1]
|
||||
|
||||
def _data(self):
|
||||
"""Read data from the file."""
|
||||
current_position = self.file.tell()
|
||||
self.file.seek(self.position)
|
||||
data = self.file.read(self.length)
|
||||
self.file.seek(current_position)
|
||||
if self.length % 2:
|
||||
data += b'\x00' # Padding byte
|
||||
return data
|
||||
data = property(_data)
|
||||
|
||||
def as_data(self):
|
||||
"""Return a RiffDataChunk read from the file."""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class RiffIndexList(RiffIndexChunk):
|
||||
def __init__(self, header, list_type, *args, **kwargs):
|
||||
self.header = header
|
||||
self.type = list_type
|
||||
self.file = kwargs.get('file', None)
|
||||
self.position = kwargs.get('position', 0)
|
||||
self.chunks = kwargs.get('chunks', [])
|
||||
|
||||
def __getitem__(self, index):
|
||||
return self.chunks[index]
|
||||
|
||||
def __setitem__(self, index, value):
|
||||
return self.chunks.__setitem__(index, value)
|
||||
|
||||
def __delitem__(self, index):
|
||||
return self.chunks.__delitem__(index)
|
||||
|
||||
def __iter__(self):
|
||||
return iter(self.chunks)
|
||||
|
||||
def __len__(self):
|
||||
"""Return total data length of the list and its headers."""
|
||||
return self.chunk_length() + len(self.type) + len(self.header) + 4
|
||||
|
||||
def chunk_length(self):
|
||||
length = 0
|
||||
for chunk in self.chunks:
|
||||
chunk_len = len(chunk)
|
||||
length += chunk_len + 8 # Header and length bytes
|
||||
length += chunk_len % 2 # Pad byte
|
||||
return length
|
||||
|
||||
def __str__(self):
|
||||
return str(self.bytes())
|
||||
|
||||
def bytes(self) -> bytes:
|
||||
"""Returns a byte representation of the chunk."""
|
||||
length_bytes = struct.pack('<I', self.chunk_length() + len(self.type))
|
||||
return self.header + length_bytes + self.type
|
||||
|
||||
class NotFound(Exception):
|
||||
"""Indicates a chunk or list was not found by the find method."""
|
||||
pass
|
||||
|
||||
def find(self, header, list_type=None):
|
||||
"""Find the first chunk with specified header and optional list type."""
|
||||
for chunk in self:
|
||||
if chunk.header == header and (list_type is None or (header in
|
||||
list_headers and chunk.type == list_type)):
|
||||
return chunk
|
||||
elif chunk.header in list_headers:
|
||||
try:
|
||||
result = chunk.find(header, list_type)
|
||||
return result
|
||||
except chunk.NotFound:
|
||||
pass
|
||||
if list_type is None:
|
||||
raise self.NotFound('Chunk \'{0}\' not found.'.format(header))
|
||||
else:
|
||||
raise self.NotFound('List \'{0} {1}\' not found.'.format(header,
|
||||
list_type))
|
||||
|
||||
def find_all(self, header, list_type=None):
|
||||
"""Find all direct children with header and optional list type."""
|
||||
found = []
|
||||
for chunk in self:
|
||||
if chunk.header == header and (not list_type or (header in
|
||||
list_headers and chunk.type == list_type)):
|
||||
found.append(chunk)
|
||||
return found
|
||||
|
||||
def replace(self, child, replacement):
|
||||
"""Replace a child chunk with something else."""
|
||||
for i in range(len(self.chunks)):
|
||||
if self.chunks[i] == child:
|
||||
self.chunks[i] = replacement
|
||||
|
||||
def remove(self, child):
|
||||
"""Remove a child element."""
|
||||
for i in range(len(self)):
|
||||
if self[i] == child:
|
||||
del self[i]
|
||||
|
||||
|
||||
class RiffDataChunk(object):
|
||||
"""A RIFF chunk with data in memory instead of a file."""
|
||||
|
||||
def __init__(self, header, data):
|
||||
self.header = header
|
||||
self.length = len(data)
|
||||
self.data = data
|
||||
|
||||
@staticmethod
|
||||
def from_data(data):
|
||||
"""Create a chunk from data including header and length bytes."""
|
||||
header, _ = struct.unpack('4s<I', data[:8])
|
||||
data = data[8:]
|
||||
return RiffDataChunk(header, data)
|
||||
|
||||
def bytes(self) -> bytes:
|
||||
"""Returns a byte array representation of the chunk."""
|
||||
return self.header + struct.pack('<I', self.length) + self.data
|
||||
|
||||
def __str__(self):
|
||||
return str(self.bytes())
|
||||
|
||||
def __len__(self):
|
||||
return self.length
|
||||
|
||||
def __getslice__(self, start, end):
|
||||
return self.data[start:end]
|
||||
|
||||
def __getitem__(self, index):
|
||||
return self.data[index]
|
||||
|
||||
|
||||
class RiffIndex(RiffIndexList):
|
||||
def __init__(self):
|
||||
self.file = None
|
||||
self.chunks = []
|
||||
|
||||
@staticmethod
|
||||
def from_file(filename: str):
|
||||
instance = RiffIndex()
|
||||
|
||||
instance.file = open(filename, 'rb')
|
||||
instance.size = instance.get_size()
|
||||
instance.scan_file()
|
||||
|
||||
return instance
|
||||
|
||||
def write(self, fh: IOBase) -> None:
|
||||
def print_chunks(chunks):
|
||||
for chunk in chunks:
|
||||
fh.write(chunk.bytes())
|
||||
if chunk.header in (b'RIFF', b'LIST'):
|
||||
print_chunks(chunk.chunks)
|
||||
|
||||
print_chunks(self.chunks)
|
||||
|
||||
def get_size(self):
|
||||
current = self.file.tell()
|
||||
self.file.seek(0, 2)
|
||||
size = self.file.tell()
|
||||
self.file.seek(current)
|
||||
return size
|
||||
|
||||
def readlen(self, length):
|
||||
buf = self.file.read(length)
|
||||
if len(buf) == length:
|
||||
return buf
|
||||
else:
|
||||
raise UnexpectedEOF(
|
||||
'End of file reached after {0} bytes.'.format(len(buf)))
|
||||
|
||||
def scan_file(self):
|
||||
header = self.readlen(4)
|
||||
if header == b'RIFF':
|
||||
length, list_type = struct.unpack('<I4s', self.readlen(8))
|
||||
chunks = self.scan_chunks(length-4)
|
||||
self.chunks.append(RiffIndexList(header, list_type, file=self.file,
|
||||
position=0, chunks=chunks))
|
||||
else:
|
||||
raise Exception('Not a RIFF file!')
|
||||
|
||||
def scan_chunks(self, data_length):
|
||||
chunks = []
|
||||
total_length = 0
|
||||
while total_length < data_length:
|
||||
header = self.readlen(4)
|
||||
total_length += 4
|
||||
|
||||
length, = struct.unpack('<I', self.file.read(4))
|
||||
total_length += length + 4 # add 4 for itself
|
||||
|
||||
position = self.file.tell()
|
||||
|
||||
if header in list_headers:
|
||||
list_type = self.readlen(4)
|
||||
data = self.scan_chunks(length-4)
|
||||
if length % 2:
|
||||
# Padding byte
|
||||
self.file.seek(1, os.SEEK_CUR)
|
||||
total_length += 1
|
||||
chunks.append(RiffIndexList(header, list_type, file=self.file,
|
||||
position=position, chunks=data))
|
||||
else:
|
||||
self.file.seek(length, os.SEEK_CUR)
|
||||
if length % 2:
|
||||
# Padding byte
|
||||
self.file.seek(1, os.SEEK_CUR)
|
||||
total_length += 1
|
||||
chunks.append(RiffIndexChunk(
|
||||
self.file, header, length, position))
|
||||
return chunks
|
||||
|
||||
def close(self):
|
||||
self.file.close()
|
||||
154
Readme.md
@@ -1,42 +1,124 @@
|
||||
[](https://akascape.gumroad.com/l/Datamosher-Pro)
|
||||
# Datamosher Pro
|
||||
<br>Datamoshing is an effect that really looks cool and if you also want to make this glitch effect with your videos, you are in the right place!
|
||||

|
||||
<br>➤Why I made this?
|
||||
<br>I was also looking for good datamoshing softwares, you can either have to use those old softwares like Avidemux or have to look for some paid plugins, but I created my own GUI based application that is Datamosher Pro which is a free project. It contains 7 different effects and more will be added in future, you can also help to make new effects. With Datamosher Pro, you can quickly and easily datamosh your videos(supports mp4, gif, avi, etc).
|
||||
<b>Datamoshing is a cool video effect and if you want to achieve this glitch with your videos, then you are in the right place!
|
||||
<br><img align="right" src="https://user-images.githubusercontent.com/89206401/141642297-7c62cf6f-7024-430f-88a2-c9cbbf0dc655.png" width="300">
|
||||
<br> Datamosher Pro is an automated glitching application for free (python version)! With Datamosher Pro you can quickly and easily datamosh your videos! </b> <br>
|
||||
### Why I made this?
|
||||
I was also looking for some good datamoshing software and I found that you have to either use those old softwares like Avidemux or have to look for some paid plugins, so I created my own python based application 'Datamosher Pro'. It contains `30+` different effects which can replicate any type of datamoshing style.
|
||||
It comes in two version, one paid and one basic free source code version.
|
||||
# DOWNLOAD
|
||||
### <p align='center'> Support Datamosher-Pro Development by purchashing its executable version for *windows* on Gumroad which have a modern UI and lots of other features. It will be really helpful!
|
||||
### <p align='center'> MODERN VERSION (SEE DETAILS)
|
||||
<br> <p align='center'> [<img src="https://img.shields.io/badge/WINDOWS-DATAMOSHER_PRO-informational?style=for-the-badge&logo=Microsoft&logoColor=blue&color=007ec6" width="500">](https://akascape.gumroad.com/l/Datamosher-Pro) </br>
|
||||
<br>
|
||||
<br>➤How to Install?
|
||||
<br>You can either use the python based version for viewing logs and changing source code if you want, but if you are looking for faster renders then download the executable version of Datamosher Pro from the release page(https://github.com/Akascape/Datamosher-Pro-GUI-/releases/tag/Datamosher_Pro.exe)
|
||||
<br>There is no malware or difference in the exe version(as the same python version is converted to .exe using Auto-Py-To-Exe Converter).
|
||||
<br>Note: For python users, make sure you have all the assets with the python file and Imageio module installed in your system if not then open CMD and type"pip install imageio" and it will be installed.
|
||||
### <p align='center'> FREE BASIC SOURCE CODE VERSIONS
|
||||
<br> <p align='center'> [<img src="https://img.shields.io/badge/Python_Version-Windows-informational?style=flat&logo=Microsoft&logoColor=blue&color=1bdce3" width=300>](https://github.com/Akascape/Datamosher-Pro/releases/download/Datamosher_Prov1.7/Datamosher_Pro-python_version-win.zip)
|
||||
<br> <p align='center'> [<img src="https://img.shields.io/badge/Python_Version-MacOS-informational?style=flat&logo=apple&logoColor=b0b5b9&color=b2b7bb" width=300 height=35>](https://github.com/Akascape/Datamosher-Pro/releases/download/Datamosher_Prov1.7/Datamosher_Pro-python_version-mac.zip)
|
||||
<br> <p align='center'> [<img src="https://img.shields.io/badge/Python_Version-Linux-informational?style=flat&logo=linux&logoColor=black&color=eaea4a" width=300 height=35>](https://github.com/Akascape/Datamosher-Pro/releases/download/Datamosher_Prov1.7/Datamosher_Pro-python_version-linux.zip) <br> Don't forget to give a ⭐ :) </p>
|
||||
|
||||
# How to Install?
|
||||
- For those who are using the python-version,
|
||||
<br> Download the correct python version (3.10+ recomended) and make sure you have python installed properly. Extract the zip file and open the "datamosher_pro-python_version" folder and just run that Datamosher-Pro.py file. If any module error pops up then just click on yes and the required modules will get downloaded automatically. You can also do that manually if it doesn't work. Then it is ready to use! (No python skills needed)
|
||||
- For the executable version, just extract the downloaded zip file and run the Datamosher_Pro.exe application.
|
||||
# How to Use?
|
||||
For the basic python version:
|
||||
|
||||
• Input the video file first (supported formats- mp4, gif, avi, mov, mkv, wmv)
|
||||
<br>• Choose the desired datamosh mode and the export format (mp4 is recommended)
|
||||
<br>• Use the advanced options to get more accurate results
|
||||
<br>• Check/uncheck the highest quality box for quality adjustments
|
||||
<br>• Then simply click on the datamosh button and wait for a few seconds
|
||||
<br>• After conversions, your video will be moshed and saved in the same directory
|
||||
|
||||
**Important Tip: Press "q" key in the command line whenever you want to end a long running conversion process.**
|
||||
### A documentation is also available in the [Wiki](https://github.com/Akascape/Datamosher-Pro/wiki) page
|
||||
|
||||
## Gallery
|
||||
[](https://github.com/Akascape/Datamosher-Pro/blob/Datamosher-Pro-v1.7/Demos.md)
|
||||
# Effects Info
|
||||
### Effects List available in the python version:
|
||||
<br> TIP: Major effects used for datamoshing are Classic, Bloom, Glide, Repeat, Motion Transfer, Rise, Fluid
|
||||
<br>
|
||||
<br>➤How to Use?
|
||||
<br>•Input the video file first (supported formats- mp4, gif, avi + more will be added if you demand")
|
||||
<br>•Choose the desired datamosh mode, then select the export format"
|
||||
<br>•Use advance options to get more accurate results"
|
||||
<br>•Then just click on the datamosh button, then wait for a few seconds"
|
||||
<br>•Then your video will be moshed, see the video in the directory"
|
||||
<br>•Note that if you mosh the same files in the same location again, then the new moshed file will replace the old file.
|
||||
| Effect Name | Description |
|
||||
| ----------------| --------------------------------------------------------------------- |
|
||||
| Rise | another classic i frames removal effect|
|
||||
| Shuffle | randomly shuffles chunks of video frames with the classic ffglitch datamosh (unstable with short videos)|
|
||||
| Buffer | creates ring buffers to mosh|
|
||||
| Delay | another delaying ffglitch effect|
|
||||
| Invert-Reverse | applies both inverse and reverse mode|
|
||||
| Mirror | does the mosh with ffglitch but with mirrored X|
|
||||
| Noise | makes large noisy mosh|
|
||||
| Shear | tilt the video clockwise and merges the mosh|
|
||||
| Shift | shifts random blocks of the video upwards|
|
||||
| Sink | drowns the next frame of the video in the previous one|
|
||||
| Slam Zoom | applies zoom with the sink effect|
|
||||
| Slice | randomly zooms and slices the video in parts|
|
||||
| Stop | similar to sink but stops the XY values|
|
||||
| Vibrate | works as a randomizer|
|
||||
| Zoom | simply zooms inside the moshed video|
|
||||
| Fluid | this is a ffglitch's average effect which gives a smooth liquid type motion in the video|
|
||||
| Repeat | repeats a series of p frames which gives the melting effect|
|
||||
| Motion Transfer | a powerful ffglitch feature that can transfer the vector motion data from one video to another. Make sure both videos have the same resolution, this effect is also known as style transfer/swap motion.|
|
||||
| Stretch | stretches the p-frames horizontally and vertically|
|
||||
| Glide | duplicates number of n frames and show it as a flow before reaching the p-frame|
|
||||
| Sort | sorts video frames by data size in a rapid movement|
|
||||
| Echo | duplicates the single video and apply the mosh effect in the midpoint|
|
||||
| Shake | randomly shakes the pixels/blocks throughout the video|
|
||||
| Classic | uses the traditional ffmpeg way to convert and corrupt the video by removing the i-frames|
|
||||
| Random | randomizes frame order|
|
||||
| Reverse | reverses frame order|
|
||||
| Invert | switches each consecutive frame witch each other|
|
||||
| Bloom | duplicates c times p-frame number n (c=Glitch Size; n=Frame Frequency)|
|
||||
| Pulse | duplicates groups of c p-frames every n frames|
|
||||
| Overlap | copy group of c frames taken from every nth position|
|
||||
| Jiggle | take frame from around current position. n parameter is spread size|
|
||||
| Void | gives a clean output but with distortion|
|
||||
## More effects including these ones are all available in the paid version.
|
||||
### How to use Advanced Options (Python version)?
|
||||
The advanced tab is very useful if you want accurate results. The options are:
|
||||
<br>• `Glitch Size` - tells how long/often to glitch per part (depends on the mode)
|
||||
<br>• `Frame Frequency` - tells how many frames to apply/repeat in the glitch
|
||||
<br>• `Ignore Frame` - tells whether to keep the first video frame
|
||||
<br>• `Kill Frames` - tells max framesize to kill while cleaning (For shuffle/rise mode the kill frame is number of frames that will be deleted)
|
||||
<br>• `First Frame` - tells the starting frame for the glitch
|
||||
<br>• `Last Frame` - tells the ending frame for the glitch
|
||||
<br>• `Start(sec)` - tells the starting time (in seconds) for the glitch
|
||||
<br>• `End(sec)` - tells the ending time (in seconds) for the glitch
|
||||
<br>• `Mid Point (Echo mode only)` - tells the point from where the video to repeat(echo)
|
||||
<br>
|
||||
<br>➤Effects Info:
|
||||
<br>(c is Glitch Frequency and n is Frame Frequency)
|
||||
<br>random - randomizes frame order
|
||||
<br>reverse - reverse frame order
|
||||
<br>invert - switches each consecutive frame witch each other
|
||||
<br>bloom - duplicates c times p-frame number n
|
||||
<br>pulse - duplicates groups of c p-frames every n frames
|
||||
<br>overlap - copy group of c frames taken from every nth position
|
||||
<br>jiggle - take frame from around current position. n parameter is spread size.
|
||||
<br>NOTE:
|
||||
<br>- Some modes may not support all the 4 advanced options.
|
||||
<br>- You can try experimenting with the options but don't put huge values.
|
||||
<br>- Audio glitching is only available in few modes like classic and repeat.
|
||||
# UI (BASIC PYTHON VERSION)
|
||||
| Windows | Linux | MacOS |
|
||||
| ---------| ------- | ------- |
|
||||
|  |  |  |
|
||||
# UI (PAID VERSION ONLY WINDOWS)
|
||||
### This modern UI is available in the paid version only.
|
||||

|
||||
## How It Works?
|
||||
The main issue with datamoshing is conversion of corrupted files but with Datamosher Pro you can use any video file and it will export an usable datamoshed file. But I still recomend everyone to use MP4 videos. The video is first converted to the required file format using ffmpeg (distributed **externally** with Imageio module) and then the effect is applied and the corrupted file is converted back to stable version using the same process so that the output video can directly be used in other editing softwares. All the unnecessary temp files are removed automatically.
|
||||
### Read these guides for more details about the python version:
|
||||
<br> [](https://akascape.gumroad.com/p/datamosher-pro-guide) [](https://akascape.gumroad.com/p/datamosher-pro-guide-2)
|
||||
## Conclusion
|
||||
You will not find this type of software anywhere with so many effects only for datamoshing. This program can be your companion while editing cool glitchy videos :)
|
||||
<br> As it is a new piece of software some users may find some errors and bugs (specially in the python version), but updates will be on their way.
|
||||
<br>The effects are all inspired from ItsKaspar's [tomato.py](https://github.com/itsKaspar/tomato), Joe Friedl's [pymosh](https://github.com/grampajoe/pymosh) and [FFglitch](https://ffglitch.org/).
|
||||
All the logos and designs are created by me. <br>-Akash Bora
|
||||
<br>
|
||||
<br>➤How to use Advanced Options?
|
||||
<br>The advanced tab is very useful and you can use it to get accurate results.
|
||||
<br>Glitch Frequency - tells how often to glitch (for modes that support it)
|
||||
<br>Frame Frequency - tells how many frames in the glitch (for modes that support it)
|
||||
<br>Ignored First Frame - tells whether to keep first video frames
|
||||
<br>Kill frames - tells max framesize to kill while cleaning
|
||||
<br>You can try around changing the values from 50-100 and see the results, you can visit https://github.com/itsKaspar/tomato.git to view more examples about the advanced tab.
|
||||
## License
|
||||
[<img src="https://user-images.githubusercontent.com/89206401/168461242-884f25ce-eb67-406a-9d98-cf8d0f28cb43.png" width=100>](https://github.com/Akascape/Datamosher-Pro/blob/Datamosher-Pro-v1.7/LICENSE)
|
||||
|
||||
Only the python version is licensed under MIT. The executable windows version is different and closed source.
|
||||
Note that the **FFglitch** part provided in the *releases* is not placed under this license. It is itself an independent program provided without any **modification**. When distributing an application with this package, it must be taken into account that multiple licenses are involved. See the [FFglitch's github page](https://github.com/ramiropolla/ffglitch-core/tree/master) for further details. (That source code is freely available there)
|
||||
<br>
|
||||
<br>➤User Interface:
|
||||
<br>
|
||||
<br>
|
||||
<br>➤More Info about this project:
|
||||
<br>The effects are all inspired from ItsKaspar's https://github.com/itsKaspar/tomato.git but it can only handle .avi file structure, but in Datamosher Pro you can use any video file type including mp4, avi, gif. The files are first converted to avi file using Imageio without losing any quality and then the effect is applied and then again the corrupted file is converted to stable version using the same process so that the output video can be directly used by other softwares without any error. A raw form option is also available if needed. You will not find this type of GUI program anywhere, I hope there is no error in the software but if you saw any bug then raise an issue. All the logo and designs are created by me. <br>Thanks! Made by Akash Bora (a.k.a Akascape).
|
||||
## Follow me
|
||||
[<img src="https://img.shields.io/badge/-Github-informational?style=flat&logo=github&logoColor=black&color=grey">](https://github.com/Akascape)
|
||||
[<img src="https://img.shields.io/badge/-Reddit-informational?style=flat&logo=reddit&logoColor=black&color=orange">](https://www.reddit.com/user/Akascape)
|
||||
[<img src="https://img.shields.io/badge/-YouTube-informational?style=flat&logo=youtube&logoColor=black&color=red">](https://www.youtube.com/channel/UC7naboenYq9FAo80aPUkqSw)
|
||||
[<img src="https://img.shields.io/badge/-Twitter-informational?style=flat&logo=twitter&logoColor=black&color=blue">](https://twitter.com/Akascape)
|
||||
<br> DATAMOSHING MADE EASY!
|
||||
### Current Version-1.7
|
||||
<br> [](https://www.python.org/) [](https://github.com/Akascape/Datamosher-Pro) [](https://github.com/Akascape/Datamosher-Pro)
|
||||
[](https://opensourcelibs.com/lib/capsule-render)
|
||||
|
||||