Skip to content

Commit

Permalink
updated usage
Browse files Browse the repository at this point in the history
  • Loading branch information
PK-cod3ch3mist committed Oct 31, 2021
1 parent 7351f8a commit 1c5931b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,24 @@ These packages can be installed using any package manager for python like pip, c
Also since the program **uses ANSI escape sequences**, all POSIX compliant terminals should work well. If you use windows, and the program doesn't work well, try switching to WSL (Windows Subsystem for Linux)

## A Demo
Click below to view a demo for the usage of the program. It is of lesser quality than what you would witness though, since I had to compress the screen recording to a managable size.
Click below to view a demo for the usage of the program without subtitles. It is of lesser quality than what you would witness though, since I had to compress the screen recording to a managable size.

<a href="https://drive.google.com/file/d/1B22lxNd0hxzxyd1Mgg0j_70LVKEbwZpn/view?usp=sharing">Demo Link</a>

## Usage
Navigate to the directory of the python script and run the following command
```shell
python generate.py $FILENAME $OPTION
python generate.py $VIDEO_FILENAME $SUBTITLE_FILENAME $OPTION
```
Here `$FILENAME` is the full path to the media file and `$OPTION` takes values **0 for black and white output** and **1 for true color output** (see if your terminal supports true color before enabling)
If you want to run without subtitles then
```shell
python generate.py $VIDEO_FILENAME $OPTION
```
Here `$VIDEO_FILENAME` and `$SUBTITLE_FILENAME` are the full path to the files and `$OPTION` takes values **0 for black and white output** and **1 for true color output** (see if your terminal supports true color before enabling)

## TODO
- [ ] Support 3-bit RGB (8-colors) with dithering
- [x] Support true color (24-bit RGB)
- [x] Support automatic resizing
- [x] Support B&W output
- [x] Support subtitles
37 changes: 33 additions & 4 deletions generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,36 @@ def read_media(vidfile, subfile, option):
vidcap.release()
cv2.destroyAllWindows()

vidfile = sys.argv[1]
subfile = sys.argv[2]
colored_output = int(sys.argv[3])
read_media(vidfile, subfile, colored_output)
def read_media(vidfile, option):
vidcap = cv2.VideoCapture(vidfile)
i = 0
# control frame rate in image
frame_skip = 0
os.system("clear")
while vidcap.isOpened():
# read frames from the image
success, image = vidcap.read()
if not success:
break
if i > frame_skip - 1:
# enhance the image (increase contrast and brightness) for terminal display
# TURN OFF (by commenting) IF YOU PREFER THE ORIGINAL COLOURS
if option == 1:
image = cv2.convertScaleAbs(image, alpha=1.25, beta=50)
cv2.imwrite("./data/frame.jpg", image)
i = 0
print_from_image("./data/frame.jpg", option)
continue
i += 1
vidcap.release()
cv2.destroyAllWindows()

if len(sys.argv) == 3:
vidfile = sys.argv[1]
colored_output = int(sys.argv[2])
read_media(vidfile, colored_output)
else:
vidfile = sys.argv[1]
subfile = sys.argv[2]
colored_output = int(sys.argv[3])
read_media(vidfile, subfile, colored_output)

0 comments on commit 1c5931b

Please sign in to comment.