Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- import argparse
- import cv2
- import emojipic
- import sys
- import time
- from PIL import *
- def clearscreen(n):
- print('\033[1A\033[K'*n, end='')
- def main(filename, resize):
- vc = cv2.VideoCapture(filename)
- tpf = 1.0/vc.get(cv2.CAP_PROP_FPS)
- ei = emojipic.EmojiImage()
- if vc.isOpened():
- rval = True
- while rval:
- start = time.time()
- rval, frame = vc.read()
- if rval:
- ei.fromarray(frame)
- res, height = ei.make(resize)
- print(res, end='')
- clearscreen(height)
- # determine if we need to sleep. Not really that accurate, but i'm
- # lazy and this is good enough.
- diff = time.time()-start
- if diff < tpf:
- time.sleep(tpf-diff)
- vc.release()
- if __name__ == "__main__":
- parser = argparse.ArgumentParser(
- description='Displays Emoji Animations in your terminal')
- parser.add_argument('filename', type=str, help='MP4 to display')
- parser.add_argument('--resize', type=int, default=32,
- help='How many characters to scale this to')
- args = parser.parse_args()
- main(args.filename, args.resize)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement