NOW it should work for any video file. Also documented a little. Not a lot, but a little.
This commit is contained in:
parent
19a5521201
commit
95c6f86399
|
@ -1 +1,3 @@
|
||||||
|
# This downscales the video to a crisp 160:42 (even tho its supposed to be 160:43
|
||||||
|
# Note that it's set to crop the video to be the right aspect ratio, too.
|
||||||
ffmpeg -i original.mp4 -vf "scale=160:43:force_original_aspect_ratio=increase,crop=160:43" shrunk.mp4
|
ffmpeg -i original.mp4 -vf "scale=160:43:force_original_aspect_ratio=increase,crop=160:43" shrunk.mp4
|
||||||
|
|
|
@ -5,15 +5,18 @@ import subprocess
|
||||||
import os
|
import os
|
||||||
|
|
||||||
directory = 'pbm/'
|
directory = 'pbm/'
|
||||||
# Load image and convert to '1' mode
|
|
||||||
#for filename in os.listdir(directory):
|
totalFrames = len(os.listdir(directory))
|
||||||
for i in range(7777):
|
|
||||||
|
for i in range(totalFrames):
|
||||||
|
# Read pbm file and run it through pbm2lpbm
|
||||||
f = os.path.join(directory, str(i)+".pbm")
|
f = os.path.join(directory, str(i)+".pbm")
|
||||||
fi = open(f, 'rb')
|
fi = open(f, 'rb')
|
||||||
p = subprocess.Popen("pbm2lpbm", stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
p = subprocess.Popen("pbm2lpbm", stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||||
lpbmOut = p.communicate(input=fi.read())[0]
|
lpbmOut = p.communicate(input=fi.read())[0]
|
||||||
fi.close()
|
fi.close()
|
||||||
|
|
||||||
|
# Write out new lpbm file
|
||||||
fn = 'lpbm/' + str(i) + '.lpbm'
|
fn = 'lpbm/' + str(i) + '.lpbm'
|
||||||
lpbmFile = open(fn, 'wb')
|
lpbmFile = open(fn, 'wb')
|
||||||
lpbmFile.write(lpbmOut)
|
lpbmFile.write(lpbmOut)
|
||||||
|
|
11
png2pbm.py
11
png2pbm.py
|
@ -4,11 +4,12 @@ from PIL import Image
|
||||||
import os
|
import os
|
||||||
|
|
||||||
directory = 'images/correctresolution/'
|
directory = 'images/correctresolution/'
|
||||||
i = 0
|
|
||||||
# Load image and convert to '1' mode
|
totalFrames = len(os.listdir(directory))
|
||||||
#for filename in os.listdir(directory):
|
|
||||||
for i in range(7777):
|
for i in range(totalFrames):
|
||||||
|
# I mean. Shit. It does it for me.
|
||||||
|
# But this converts the pngs to pbms (P4)
|
||||||
f = os.path.join(directory, "thumb-" + str(i) + ".png")
|
f = os.path.join(directory, "thumb-" + str(i) + ".png")
|
||||||
im = Image.open(f).convert('1')
|
im = Image.open(f).convert('1')
|
||||||
im.save("pbm/" + str(i) + ".pbm")
|
im.save("pbm/" + str(i) + ".pbm")
|
||||||
i = i + 1
|
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
|
# This takes all of the frames in the video and turns them into pngs
|
||||||
ffmpeg -i shrunk.mp4 -vf fps=24 images/fromvideo/thumb%04d.png
|
ffmpeg -i shrunk.mp4 -vf fps=24 images/fromvideo/thumb%04d.png
|
||||||
|
|
Loading…
Reference in a new issue