This project is a small script for turn a video into many txts and display them in CMD just like the origin video.
This small script is written in python 2.7, using many packages, all listed below.
- PIL : You can install
PIL
by executing an executable binary file from here. - cv2 : cv2 is the openCV packages for python. You can download
openCV
from its official site. Also, install by pippip install opencv-python
is needed. Then, installffmpeg
. Download it from here, I suggest you chose the binary file and just install it simply. After you installcv2
,numpy
andmatplotlib
will also be installed.
Just run python2 video2txt.py <parameters>
. Also, you can download the executable binary file video2txt.exe
from my cloud storage: here. The parameters are:
- --file: the video you want to transform.
- --output or -o: the directory you want to store the txts, you can use absolute path or relative path.
- --frame: how many frames you want to transform.
- --color: output "colorful" txts or just black-white txts with only '#' and space? Default is black-white. If you want more chars, set
--color=True
. - --interval: transform a frame between interval frames. For example, when interval is 0, the program will transform every frame. This parameter should not conflict with
play.py
, here, is interval is 0, then the frame parameter inplay.py
should be 25( if your video is 25 frames/s ), else if won't display well. Its default value is 24, it means 1 frame/s if video is 25 frames/s. - --width: the width of txt image.
- --height: the height of txt image.
- Example:
python2 video2txt.py --file=test.avi --output=pic --frame=600 --interval=0 --width=80 --height=60
, this command will transform first 600 frames oftest.avi
into txts, these txts will be stored in./pic
, with80x60
dpi.
run python2 play.py <parameters>
. Also, you can download the executable binary file play.exe
from my cloud storage: here. The parameters are:
- --dir: the txts' path, the directory should only contain the txts.
- --frame: how many txts displayed per sec.
- Example:
python2 play.py --dir=pic --frame=24
means display all txts inpic
with 24 txts per sec.
You may find openCV
for python is too hard to install. Several tips here to help you, or give you another choice.
- Cannot open video with my tool? You can add
openCV\soureces\3rdparty\ffmpeg
into your environment variable, or copyopencv_ffmpeg.dll
andopencv_ffmpeg_64.dll
fromopenCV\soureces\3rdparty\ffmpeg
to your install directory ofpython2.7
. Also, change their filenames. Check youropencv-python
version byimport cv2
,cv2.__version__
, for example, 3.1.0, then changeopencv_ffmpeg.dll
intoopencv_ffmpeg310.dll
and changeopencv_ffmpeg_64.dll
intoopencv_ffmpeg310_64.dll
. Try again! - Afraid of so confused steps? Just use
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.png
to change your video into several.png
images. HereWxH
is your dpi,foo.avi
should be replaced by your video. After that, change my code and read those images.
- 2016-9-22: Add this project.
- 2016-9-23: Two methods with args.
- 2016-10-7: Build repository.
All codes in this repository are licensed under the terms you may find in the file named "LICENSE" in this directory.