ASCIIPlayer : Golang写的ASCII码播放器

news/2023/12/1 9:07:48

ASCIIPlayer : Golang写的ASCII码播放器

ASCIIPlayer是一个基于Image2ASCII的ASCII码播放器,可以播放图片,gif动图,视屏(还在开发中)等,提供了类库和命令行工具方便使用。

HomePage: https://github.com/qeesung/as... 欢迎Star

先上一个效果图

ascii_fire.gif?raw=true

特性

  • 支持在终端中播放一般的图片,比如PNG,JPEG,也支持播放GIF动图和视屏。
  • 支持将一个图片,PNG,JPEG类型和GIF动图和视屏直接编码成为一个ASCII码图片。
  • 支持搭建一个Http Server来分享ASCII图片到远程的一个客户端。

工作原理

  1. 首先将任何一个输入的文件通过解码器解码成个一个帧序列,不同的文件有不同的解码器,比如GIF文件有GifDecoder
  2. 然后将解码出来的帧序列通过Image2ASCII转换器转换成ASCII码图片
  3. 然后将转换以后的ASCII图片输出到不同的IO中去,其中包括:

    • 输出到一个一般文件中(Encode模式): 这里我们只能逐帧,逐像素的将转化以后的ASCII图像写到文件中去。
    • 输出到终端(Play模式): 直接将转换以后的图像按照一定的频率输出到终端即可。
    • 输出到远端客户端(Server模式): 这里和输出到终端的原理类似,只是输出到了远端客户端所在的终端。
                 +---------------+                                                  +---------+
                 |               |                                                  |         |
          +------> Gif Decoder   |                                              +---> Encoder +---> file
          |      |               |                                              |   |         |
          |      +---------------+                                              |   +---------+
          |      +---------------+                +-------------+               |   +---------+
          |      |               |                |             |               |   |         |
Input File+------> Image Decoder +---> Frames +-->+ Image2ASCII +->ASCII Frames-+---> Player  +---> stdout
          |      |               |                |             |               |   |         |
          |      +---------------+                +-------------+               |   +---------+
          |      +---------------+                                              |   +---------+
          |      |               |                                              |   |         |
          +------> Video Decoder |                                              +---> Server  +---> socket
                 |               |                                                  |         |
                 +---------------+                                                  +---------+

安装

go get -u github.com/qeesung/asciiplayer

命令行使用

    _    ____   ____ ___ ___ ____  _        _ __   _______ ____
   / \  / ___| / ___|_ _|_ _|  _ \| |      / \\ \ / / ____|  _ \
  / _ \ \___ \| |    | | | || |_) | |     / _ \\ V /|  _| | |_) |
 / ___ \ ___) | |___ | | | ||  __/| |___ / ___ \| | | |___|  _ <
/_/   \_\____/ \____|___|___|_|   |_____/_/   \_\_| |_____|_| \_\
>>>Version  : 1.0.0
>>>Author   : qeesung
>>>HomePage : https://github.com/qeesung/asciiplayer

asciiplayer is a library that can convert gif and video to ASCII image
and provide the cli for easy use.

Usage:
  asciiplayer [command]

Available Commands:
  encode      Encode gif or video to ascii gif or video
  help        Help about any command
  play        Play the gif and video in ASCII mode
  server      Server command setup a http share server
  version     Show the version

Flags:
  -D, --debug   Switch log level to DEBUG mode
  -h, --help    help for asciiplayer

Use "asciiplayer [command] --help" for more information about a command.

播放命令 play

播放命令直接在终端中播放对应的媒体,比如PNG和GIF图片。

可以通过asciiplayer play -h来获得更多细节

图片描述

Play 例子

通过适配屏幕的方式播放GIF

asciiplayer play demo.gif

缩小为原来的十分之一,然后播放GIF

asciiplayer play demo.gif -r 0.1

缩放成固定的长和宽,然后播放GIF

asciiplayer play demo.gif -w 100 -h 40

播放一个PNG图片

asciiplayer play demo.png

编码命令 encode

编码命令可以将一个PNG图片或者是GIF动图,视屏文件转化成一个ASCII的文件

可以运行asciiplayer encode -h来获得更多细节

图片描述

输入文件eye.gif

图片描述

输出文件ascii_eye.gif

图片描述

Encode 例子

讲一个GIF文件demo.gif编码为ASCII的Gif文件output.gif

asciiplayer encode demo.gif -o output.gif

指定输出ASCII字符大小的情况下,讲一个GIF文件demo.gif编码成ASCII的GIF动图文件output.gif

asciiplayer encode demo.gif -o output.gif --font_size=5

将GIF动图demo.gif缩放为原来的十分之一,然后编码成ASCII的GIF动图文件output.gif

asciiplayer encode demo.gif -o output.gif -r 0.1

编码一个jpeg文件,然后输出一个ASCII的output.png文件

asciiplayer encode demo.jpeg -o output.png

服务命令 server

可以搭建一个Http Server,然后将转换以后的图片分享到远端的客户端。

搭建服务

$ asciiplayer server demo.gif
# Server available on : http://0.0.0.0:8080

远端访问

$ curl http://hostname:8080
# play ascii image here

可以通过运行命令asciiplayer server --help来获得更多细节

图片描述

Server 例子

输入demo.gif,并以默认端口8080启动一个http服务器

asciiplayer server demo.gif

输入demo.gif,并以自定义端口8888启动一个http服务器

asciiplayer server demo.gif --port 8888

输入一个demo.png图片,并且启动http 服务器

asciiplayer server demo.png

一些例子

Raw ImageASCII Image
图片描述图片描述
图片描述图片描述

HomePage: https://github.com/qeesung/as... 欢迎Star


http://www.niftyadmin.cn/n/4131602.html

相关文章

运维之道 | LNMP 环境部署 Memcache 缓存(编译安装)

一、部署LNMP环境 运维之道 | CentOS7.6 Nginx1.8 MySQL5.6 PHP7.3 环境部署&#xff08;编译安装&#xff09; 使用firewall-cmd命令开放80及443端口: firewall-cmd -permanent -zonepublic -add-servicehttp firewall-cmd -permanent -zonepublic -add-servicehttps二、…

布局的运用

<html xmlns"http://www.w3.org/1999/xhtml"> <head> <meta http-equiv"Content-Type" content"text/html; charsetutf-8" /><title>中国海洋大学</title><style type"text/css">*{margin:0px au…

vc建立一个窗口的流程

上一篇中我给各位说了一般人认为C中较为难的东西——指针。其实对于C&#xff0c;难点当然不局限在指针这玩意儿上&#xff0c;还有一些有趣的概念&#xff0c;如模板类、虚基类、纯虚函数等&#xff0c;这些都是概念性的东西&#xff0c;几乎每一本C书上都会介绍&#xff0c;而…

第七课 创建计算字段

7.1 计算字段 存储在表中的数据都不是应用程序所需要的。我们需要直接从数据库中检索出转换、计算或格式化过的数据&#xff0c;而不是检索出数据&#xff0c;然后再在客户端应用程序中重新格式化。 7.2 拼接字段 在MySQL中使用concat函数进行拼接 select concat(vend_name,(,…

Hadoop日志文件

初学者运行MapReduce作业时&#xff0c;经常会遇到各种错误&#xff0c;往往不知所云&#xff0c;一般直接将终端打印的错误贴到搜索引擎上查找&#xff0c;以借鉴前人的经验。 对于hadoop而言&#xff0c;当遇到错误时&#xff0c;第一时间应是查看日志&#xff0c;日志里通产…

BZOJ.2243.[SDOI2011]染色(树链剖分)

题目链接 //17440kb 3760ms //维护区间颜色数、最左、最右颜色即可。 //-(L[]R[])要加括号&#xff01;woc才发现。 #include <cstdio> #include <cctype> #include <algorithm> //#define gc() getchar() #define gc() (SSTT&&(TT(SSIN)fread(IN,…

ORA-09817/Linux-x86_64 Error: 28: No space left on device/ORA-01075

2019独角兽企业重金招聘Python工程师标准>>> 1、通过sqlplus / as sysdba在服务器上无法登录oracle&#xff0c;并提示一下错误 ERROR: ORA-09817: Write to audit file failed. Linux-x86_64 Error: 28: No space left on device Additional information: 12 ORA-0…

原来腾讯还出过一个开源项目libco

虽然只能在OpenSUSE上使用&#xff0c;还是应该赞一个的。转载于:https://www.cnblogs.com/raison/p/4009803.html

JS的深拷贝

var obj {name: "wuyongyu",age: 18 } 第一种方式&#xff1a; function deepClone(obj){// 判断传入的数据类型 - 数组或者对象var o obj instanceof Array ? [] : {}// 对数据进行拷贝 - 分情况for(var k in obj){if(typeof obj[k] object && obj[k] !…

Python接受流式输入

随笔记录——Python接受终端入若干行输入 Python接受终端的若干行输入时&#xff0c;比较常用的input()不再好用。 1. 导入sys模块&#xff1a; import sys2. for循环接受输入&#xff1a; for line sys.stdin:# todo 3. Debug可ctrlD转载于:https://www.cnblogs.com/thisyan/p…

清北集训Day3T1(转换)

这题可能是我与正解里的最近的一次了&#xff0c;可以还是sb的把正解叉了。 正解其实比较显然&#xff1a;因为$f(x)$只有81个取值&#xff0c;所以我们可以枚举$f(x)$&#xff0c;然后计算$x$&#xff0c;再判断$x$是否可以转化为$f(x)$ 刚开始以为一个$f(x)$会对应很多$x$&am…

视频会议管理接口

1.概述 1.1.用途 主要用途是对会议进行管理 1.2.适用版本 略 1.3.通信协议 本规范中&#xff0c;业务系统是通信的服务器端&#xff08;简称“服务器”&#xff09;&#xff0c;信令服务器是通信客户端&#xff08;简称“客户端”&#xff09;。客户端和服务器通过HTTP协议通信…

classmethod VS staticmethod

转载于:https://www.cnblogs.com/morgana/p/8655067.html

matlab 函数的编写与调用

matlab中写个函数,在主程序中调用该函数的方法 跟其它的编程语言都一样&#xff0c;但是子函数与主函数要存于不同的文件中&#xff0c;文件名就是函数名字。文件必须保存在current directory中&#xff0c;才能调用。 函数的基本结构&#xff1a; function [返回变量列表]函数…

Android编译系统(Android.mk文件详解)

【Android-NDK&#xff08;Native Development Kit&#xff09; docs文档】NDK提供了一系列的工具&#xff0c;帮助开发者快速开发C&#xff08;或C&#xff09;的动态库&#xff0c;并能自动将so和java应用一起打包成apk。Android.mk文件是GNU Makefile的一小部分&#xff0c…

人工智能学习资料汇总

机器学习 各种优化器的总结和比较&#xff08;各种梯度下降算法模型的对比&#xff09;
最新文章