aboutsummaryrefslogtreecommitdiff
path: root/src/VHSVideo.py
diff options
context:
space:
mode:
authordeepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>2020-07-07 14:55:32 +0000
committerGitHub <noreply@github.com>2020-07-07 14:55:32 +0000
commit52694cd7ad9bbd5c514de448d46ac3c7ef0aef9e (patch)
tree1157294180ebe84486750fa39c54fa1a26023417 /src/VHSVideo.py
parent6624f8fb1aa7cf4d67c8b5256158515c06f55686 (diff)
Format code with Black
Diffstat (limited to 'src/VHSVideo.py')
-rw-r--r--src/VHSVideo.py51
1 files changed, 33 insertions, 18 deletions
diff --git a/src/VHSVideo.py b/src/VHSVideo.py
index e644074..17493b3 100644
--- a/src/VHSVideo.py
+++ b/src/VHSVideo.py
@@ -8,16 +8,18 @@ import logzero
from logzero import logger
from logzero import setup_logger
-def SaveVid(path):
- vidObj = cv2.VideoCapture(path)
- count = 0
- success = 1
- while success:
- success, image = vidObj.read()
- cv2.imwrite("frames/"+str(count)+".jpg", image)
- #os.rename("frames/"+str(count)+".jpg", os.path.splitext("frames/"+str(count)+".jpg")[0])
- count += 1
-
+
+def SaveVid(path):
+ vidObj = cv2.VideoCapture(path)
+ count = 0
+ success = 1
+ while success:
+ success, image = vidObj.read()
+ cv2.imwrite("frames/" + str(count) + ".jpg", image)
+ # os.rename("frames/"+str(count)+".jpg", os.path.splitext("frames/"+str(count)+".jpg")[0])
+ count += 1
+
+
def Style(pathToFrames):
files = [f for f in os.listdir(pathToFrames) if isfile(join(pathToFrames, f))]
count = 0
@@ -26,7 +28,7 @@ def Style(pathToFrames):
f = str(i)
fi = pathToFrames + f
out = fi + ".jpg"
-
+
generateVHSStyle(fi, out, silence=True)
os.rename(out, fi)
print("--------")
@@ -41,29 +43,42 @@ def Style(pathToFrames):
os.system(c)
os.chdir(cwd)
+
def generateVideo(outfile, path, infile):
frame_array = []
files = [int(f) for f in os.listdir(path) if isfile(join(path, f))]
files.sort()
- duration = subprocess.check_output(['ffprobe', '-i', infile, '-show_entries', 'format=duration', '-v', 'quiet', '-of', 'csv=%s' % ("p=0")])
- fps = len(files)/float(duration)
+ duration = subprocess.check_output(
+ [
+ "ffprobe",
+ "-i",
+ infile,
+ "-show_entries",
+ "format=duration",
+ "-v",
+ "quiet",
+ "-of",
+ "csv=%s" % ("p=0"),
+ ]
+ )
+ fps = len(files) / float(duration)
print("FPS", fps)
for i in range(len(files)):
- filename=path + str(files[i])
+ filename = path + str(files[i])
img = cv2.imread(filename)
height, width, layers = img.shape
- size = (width,height)
+ size = (width, height)
frame_array.append(img)
- out = cv2.VideoWriter(outfile,cv2.VideoWriter_fourcc(*'MP4V'), fps, size)
+ out = cv2.VideoWriter(outfile, cv2.VideoWriter_fourcc(*"MP4V"), fps, size)
for i in range(len(frame_array)):
out.write(frame_array[i])
out.release()
def VHS_Vid(infile, outfile):
- path = './frames/'
+ path = "./frames/"
os.system("rm frames/*")
os.system("mkdir frames")
logger.info("Exctracting Frames")
@@ -84,4 +99,4 @@ def VHS_Vid(infile, outfile):
os.remove("output-audio.aac")
-#VHS_Vid("video.mp4","video2.mp4") \ No newline at end of file
+# VHS_Vid("video.mp4","video2.mp4")