TXT Player （视频转TXT播放器）
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
PILby executing an executable binary file from here.
- cv2 : cv2 is the openCV packages for python. You can download
openCVfrom its official site. Also, install by pip
pip install opencv-pythonis needed. Then, install
ffmpeg. Download it from here, I suggest you chose the binary file and just install it simply. After you install
matplotlibwill also be installed.
Turn video into txts
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
- --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 in
play.pyshould 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.
python2 video2txt.py --file=test.avi --output=pic --frame=600 --interval=0 --width=80 --height=60, this command will transform first 600 frames of
test.aviinto txts, these txts will be stored in
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.
python2 play.py --dir=pic --frame=24means display all txts in
picwith 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\ffmpeginto your environment variable, or copy
openCV\soureces\3rdparty\ffmpegto your install directory of
python2.7. Also, change their filenames. Check your
cv2.__version__, for example, 3.1.0, then change
opencv_ffmpeg310_64.dll. Try again!
- Afraid of so confused steps? Just use
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.pngto change your video into several
WxHis your dpi,
foo.avishould 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.