Code Monkey home page Code Monkey logo

charanimeplayer's Introduction

CharAnimePlayer

用opencv读取视频帧,压缩,构造灰度字符串,用字符串替换像素。实现在终端播放字符动画。

安装

需要:

  • python3
  • opencv
  • pygame
  • moviepy

安装: sudo pip install -r requirements.txt

样例

在终端播放“鸡你太美”

python charAnimePlayer.py jinitaimei2.dat -fps 20 #每秒20帧

效果如下:

即时播放

播放指定的mp4文件:

python charAnimePlayer.py <file> [option]

选项:-width,-height,-fps设置宽高与帧率,还需带上--raw

Bad Apple样例(50帧,宽70字符,高35字符):

python charAnimePlayer.py -fps 50 -width 70 -height 35 bad-apple.mp4 --raw

当附带--audio选项时,可以开启声音(尚未解决音画同步的问题)。

该种播放方式是一边转化每一帧为灰度字符串,一边播放,配置不行电脑的可能会卡。建议用该种模式调试适合你的屏幕的宽高以及帧率,然后选用下面预处理播放的方式获得更流畅的体验。

fps,width,height需要根据自己的电脑调试。fps设置在1-60内,widthheight是指宽高的字符数,建议不要超过100

预处理播放

为解决即时播放的卡顿问题,可以使用预处理播放。预处理后生成的预处理文件不需要依赖其他库也能播放。

对于一个bad-apple.mp4文件预处理播放的方式如下:

python3 charAnimeBuilder.py bad-apple.mp4 -width 100 -height 100 -o bad-apple.dat

预处理需要设置宽高,输出路径。完成后会生成bad-apple.dat预处理文件,然后直接用它播放:

python charAnimePlayer.py bad-apple.dat -fps 50

播放预处理文件任可以指定帧率,但不可以设置宽高和播放声音了。

charanimeplayer's People

Contributors

xuranus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.