Last active
September 14, 2019 20:53
-
-
Save SubhrajitPrusty/5f303202c615e42e12b1a640322f9fec to your computer and use it in GitHub Desktop.
Make a poly video using wallgen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from wallgen import * | |
import os | |
from PIL import Image | |
import numpy as np | |
import cv2 | |
import sys | |
if len(sys.argv) < 1: | |
print("Needs file path ") | |
sys.exit(1) | |
fn = sys.argv[1] | |
if not os.path.exists(fn): | |
print("Invalid path") | |
sys.exit(1) | |
ERASE_LINE = '\x1b[2K' | |
CURSOR_UP_ONE = '\x1b[1A' | |
cap = cv2.VideoCapture(fn) | |
ret, frame = cap.read() | |
img = Image.fromarray(frame) | |
width = img.width | |
height = img.height | |
wshift = img.width//10 | |
hshift = img.height//10 | |
width += wshift*2 | |
height += hshift*2 | |
pts = genPoints(10000, width, height) | |
fourcc = cv2.VideoWriter_fourcc(*'XVID') | |
out = cv2.VideoWriter('vid.avi', fourcc, 24, (img.width, img.height)) | |
fr = 1 | |
while(cap.isOpened()): | |
ret, frame = cap.read() | |
if ret: | |
print(CURSOR_UP_ONE + ERASE_LINE + CURSOR_UP_ONE) | |
print(fr) | |
fr+=1 | |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) | |
img = Image.fromarray(frame) | |
pimg = genPoly(img.width, img.height, img, pts, wshift, hshift, False, pic=True) | |
cimg = cv2.cvtColor(np.array(pimg), cv2.COLOR_RGB2BGR) | |
out.write(cimg) | |
else: | |
break | |
cap.release() | |
out.release() | |
cv2.destroyAllWindows() | |
getMusic = "ffmpeg -i '{}' audio.mp3 -y".format(fn) | |
os.system(getMusic) | |
stitchVideo = "ffmpeg -i audio.mp3 -i vid.avi -c:v libx264 out.mp4 -y" | |
os.system(stitchVideo) | |
Noisk8
commented
Sep 14, 2019
via email
thanks dude !
Noi
El mar., 10 sept. 2019 a las 1:20, Subhrajit Prusty (<
notifications@github.com>) escribió:
… Hello,
The script needs a video file as a command line argument to work.
eg: python wallgen-vid.py /path/to/some_video.mp4
You also need ffmpeg installed.
Nevertheless, the script is really old and lots of code have changed in
wallgen.
You can try to run it, but I don't guarantee it working smoothly.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<https://gist.github.com/5f303202c615e42e12b1a640322f9fec?email_source=notifications&email_token=AEHDR4F7L7CXI6CEWILELWTQI44DLA5CNFSM4IU7RR62YY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFYNYW#gistcomment-3021707>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEHDR4CXB4BN7NBHABY3EL3QI44DLANCNFSM4IU7RR6Q>
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment