Skip to main content

让终端可以播放视频!

Project description

🎞️ console-player

视频播放器,但终端
这个项目包含了FFmpeg的LGPL构建

这个项目的图标使用到了Iconpark的三角形图标,这个部分使用Apache License 2.0授权

📦 安装

# Windows用户没有安装FFmpeg的,或者使用其他系统的
$ pip install console-player
# Windows用户安装了FFmpeg的
$ pip install console-player-noffmpeg

❓ 用法

# 播放视频
$ consoleplay <CPVID文件>

# 生成CPVID文件
$ cpvgen # 交互生成
$ cpvgen  <视频文件> <输出的CPVID文件,后缀必须是(.cpv;.cpvt;.zip)的任意一项> # 不让你选择文件的交互生成

# 在终端显示图片
$ consolepic <图片文件>

# 显示版本信息 (三选一)
$ consoleplay
$ consolepic

⚙️ API用法

from consoleplay import RGB,pic2terminal
from colorama import Style,init
init()


# 将图片打印到终端
pic2terminal("图片文件路径")

# 打印RGB颜色的字体
print(RGB(255,0,0)+"红色字体"+Style.RESET_ALL)

🔨 构建

# Windows带FFmpeg
$ python setup.py bdist_wheel --have-ffmpeg

# Windows不带FFmpeg (注意包名变成了console-player-noffmpeg)
$ python setup.py bdist_wheel

# 类UNIX
$ python setup.py bdist_wheel --others

🛠️ CPVID文件的手工生成

首先,你要知道CPVID本质上其实就是7z文件,只是后缀不同罢了
知道了这个特性,然后创建一个新目录,并以这个结构创建文件(夹)

你的目录
|-- manifest.json
|-- audio.mp3
|-- frames
| |-- 1.jpg
| |-- 2.jpg
| |-- ...
| |-- n.jpg

如果你要打包CPVT格式的文件的话,请你把要输出的文字放入frames/n.txt中 (或使用xz压缩后使用frames/n.txt.xz) ,以替换franes/n.jpg中的图片

然后,填充audio.mp3为你的音频

接着,往manifest.json以这个格式写入内容

{
  "frames":, //视频帧数,填入数字,比如3500
  "fps":, //视频的帧率,填入数字,要和frames和音频长度吻合,否则播放报错,比如20
  "type":, //视频类型,比如"cpvt"或"cpv"
  "xz":, //你的cpvt类型的文件是否使用了xz压缩,填true或false
  "height":, //视频高度,暂时没有实现,比如60
}

最后,把这个目录的所有内容压缩到7z文件,把后缀一改,搞定!

📝 更新日志

1.02

  • 从此版本开始,使用MPL 2.0许可证,以前的版本使用LGPL 3.0许可证

  • 适应了py7zr 1.0.0-rc2的不兼容更改,它移除了readall方法而需要使用BytesIOFactory实现

  • 把LOGO显示改成了ASCII艺术

  • 我发现用Python来写这个库会遇到性能瓶颈,所以我未来会写一个C++重写的版本,原Python版本会把后端也改用C++实现

1.01.1

  • 😅包有点乱,整理了一下

1.01

  • 简单修复了源码包会包含ffmpeg的问题
  • 更新了FFmpeg的版本,从7.1到master

1.00

  • 第一次发布

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

console_player-1.2.tar.gz (40.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

console_player-1.2-py3-none-win_amd64.whl (52.9 MB view details)

Uploaded Python 3Windows x86-64

console_player-1.2-py3-none-any.whl (40.5 kB view details)

Uploaded Python 3

File details

Details for the file console_player-1.2.tar.gz.

File metadata

  • Download URL: console_player-1.2.tar.gz
  • Upload date:
  • Size: 40.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for console_player-1.2.tar.gz
Algorithm Hash digest
SHA256 c0c7056fc0868e6ea31f7c13c83e02f010f8a9c970f9c6afe20e107bb293a3d2
MD5 b78e383b92807a7ddf4f60dcab551ae4
BLAKE2b-256 4e56631b7556e3fe823d78a6595d8fc7d0c65a9ecba1acdf55ce5cadf9b52771

See more details on using hashes here.

File details

Details for the file console_player-1.2-py3-none-win_amd64.whl.

File metadata

  • Download URL: console_player-1.2-py3-none-win_amd64.whl
  • Upload date:
  • Size: 52.9 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for console_player-1.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 5da2ac9c091517638960899a0b1f3a9175d9a752f1ee56ddda21c3fc76d6c8fb
MD5 d2ada9065dd89ef0de0a3120cde2649d
BLAKE2b-256 623abae39599e0500418d40f2c6a3f724e0e8db38007093c220fb9db96642254

See more details on using hashes here.

File details

Details for the file console_player-1.2-py3-none-any.whl.

File metadata

  • Download URL: console_player-1.2-py3-none-any.whl
  • Upload date:
  • Size: 40.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for console_player-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5edb88e919f5415976717777c3f51c8477c1716ee82ce43af3efd58313725997
MD5 57ee383f873253ca511aaf4923929057
BLAKE2b-256 c82a0a3f8e9f85bf5093b5132e7a62a398347eccef09a7dd07f291eda77d18f8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page