This project is no longer maintained
视频字符画
- CharDraw.py 最初版本字符画
- CharDraw_compress.py 带压缩版本字符画
- CharDraw_thread.py 带压缩和多线程版本字符画
- CharDraw_frame 带多线程压缩和抽帧版本字符画
- 直接clone或者下载zip(zip好,多半不会更新了)
- 下载pillow和opencv-python库(numpy在opencv里面有带,国内建议pip国内镜像)
- 根据最上面提示更改变量
- 运行
- 引入一些需要的库
- 获取视频帧数,为导出做准备(除frame)
- 截取视频所有的帧,之后再一帧一帧转换成字符画
- 把所有转换成字符画的帧再合并成视频
- fps计算方法
CharDraw_frame.py文件特有的
有两个变量:fps和count
fps是最终输出的fps数,count是第几帧输出一帧
源代码:
while True: ... if a % count == 0: # 此处a是计算循环执行了多少次,从1开始 # 保存图片 ... ...循环次数取余count等于0就截取一帧
那么我有一个30fps的一支视频
那么我count可以等于2,fps就是15
大概就是这样
- 输出文件压缩
除CharDraw.py原始版本都有的图片压缩
在函数imageToChar里面倒数第三行有一个
[cv2.IMWRITE_JPEG_QUALITY, 2]这个是压缩的格式,后面那个2可以变动,1-100以内
0的话就是死命压缩,只不过画质不太好
如果想要看清楚字符的话可以考虑把这个调高一点,但相对应的
输出图片所占硬盘大小也会很高
- 如果你不想删除输出的图片的话,把倒数第四行那个daleteImg()给他注释掉就好
- Fork 本仓库
- 新建 Feat_xxx 分支
- 提交代码
- 新建 Pull Request
This English version is mostly Google Translate and cannot guarantee the accuracy of the translation, please refer to Chinese as much as possible, thank you for your understanding
Video Char Draw
- CharDraw.py First version
- CharDraw_compress.py A version with compress
- CharDraw_thread.py A version with compress and thread
- Download ZIP or clone(Probably not upgrade)
- Download libraries pillow and opencv-python(library numpy will install with opencv)
- Modify the variables as indicated above
- Run code
- Introduce some required libraries
- Get the number of video frames to prepare for export (except frame)
- Intercept all the frames of the video, and then convert them frame by frame to character painting
- Combine all the frames converted into character paintings and merge them into video
- fps calculation method
fps just in CharDraw_frame.py
There are two variables: fps and count
fps is the number of FPS of the final output, count emmm......
There is source code:
a = 0 while True: a += 1 if a % count == 0: # save image ... ...
- Output file compression
The third to last line in function imageToChar
[cv2.IMWRITE_JPEG_QUALITY, 2]You can change the 2 to 0-100
If you want to see the characters clearly, you can consider raising this a little bit, but the corresponding
The output image will also take up a large amount of hard disk size
- If you do n’t want to delete the output image, comment out the daleteImg () on the penultimate line
- Fork the repository
- Create Feat_xxx branch
- Commit your code
- Create Pull Request