Skip to main content

A simple converter CLI that convert your video into .dur file

Project description

dur_convert

A simple converter CLI that convert your video into .dur file

I. Introduction

As said in the description, this is a tool to convert a video into .dur file format (specifically version 7). See more about the .dur format

It first slicing video into multiple image, then convert the image into an ansi and note down the color at the position.

Normally, a terminal character height is double compare to its width, so this project use a trick is using the upper half block unicode character ("▀"). Not working for now since it is the known issue of durdraw (or Python's curses), see more here

The upper half trick (Not working for now)

This program compress two pixels into one character, then set the foreground color to the upper pixel and the background to the lower one.

The workaround of current issue

As mentioned before, an known issue in Python's curses library make coloring the background with 256 color is impossible. So the --half-frame flag is introduced as the workaround. The --half-frame flag still compressing two pixels into one character, but this time, it use the full block one ("█") and choose the upper pixel color.

II. Installation

You can install it from PYPI using your favorite tool:

pip install dur_converter

Or

uv add dur_converter

Then calling it with using dc keyword:

dc --help
# usage: dc [-h] [-R <Width>x<Heigth>] [-c COL] [-r ROW] [-f FPS] [-H] [-o OUTPUT] input
# 
# A simple python script that convert your video into .dur file
# 
# positional arguments:
#   input                 the input
# 
# options:
#   -h, --help            show this help message and exit
#   -R, --resolution <Width>x<Heigth>
#                         the target output resolution
#   -c, --col COL         the target output width, will be overwritten --resolution flag
#   -r, --row ROW         the target output height, will be overwritten --resolution flag
#   -f, --fps FPS         the target output frame-per-second
#   -H, --half-frame      Cut the height in half, result in wider image but reduced quality
#   -o, --output OUTPUT   output destination, default to ./data/out.dur
# 
# Originally, this software is targetted for Ly (a screen manager for Linux)

Or using uvx

uvx --from dur_converter dc --help
# usage: dc [-h] [-R <Width>x<Heigth>] [-c COL] [-r ROW] [-f FPS] [-H] [-o OUTPUT] input
# 
# A simple python script that convert your video into .dur file
# 
# positional arguments:
#   input                 the input
# 
# options:
#   -h, --help            show this help message and exit
#   -R, --resolution <Width>x<Heigth>
#                         the target output resolution
#   -c, --col COL         the target output width, will be overwritten --resolution flag
#   -r, --row ROW         the target output height, will be overwritten --resolution flag
#   -f, --fps FPS         the target output frame-per-second
#   -H, --half-frame      Cut the height in half, result in wider image but reduced quality
#   -o, --output OUTPUT   output destination, default to ./data/out.dur
# 
# Originally, this software is targetted for Ly (a screen manager for Linux)

III. Usage

Note: This some part of this usage guide is built intentionally for Ly (a screen manager for Linux), which will be noted with asterisk "*"

1. Download your video and put it somewhere, saying /path/to/video

2. Call the converter

dc -c 240 -r 150 -f 5 -o /path/to/output /path/to/video

Here, specify your:

  • Resolution with flag --row and --col or flag --resolution. Recommending

    Recommending 240x150 *

  • (Optionally) FPS with flag --fps, this flag will downsample your video, or in other word, slicing your video to reduce the size of the output.

    Recommending 5 FPS for video under 10 secs and 1-2 for longer. *

  • (Optionally) using --half-frame to compress your video, as mention in this section

  • (Optionally) the output path with --output, if it is not specified, default to ./data/out.dur

Note: The input and output path must be the path to input and output FILE, not DIRECTORY

3. Wait for it running:

dc -c 240 -r 150 -f 5 data/blackhole.mp4
# 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 105/104.58333333333334 [00:03<-00:00, 27.24it/s]
# Done :D

4. Grab the result :D

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

dur_converter-0.2.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

dur_converter-0.2.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file dur_converter-0.2.1.tar.gz.

File metadata

  • Download URL: dur_converter-0.2.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dur_converter-0.2.1.tar.gz
Algorithm Hash digest
SHA256 bb01a99929d7df413e4b541d0853d749933fb809231ef47fa6ea2319a2ee9e2c
MD5 85f9b157896ea5dda8f2630911352176
BLAKE2b-256 ec6f90724cc9f4c17de72d7a4ffe425f9481c40afda2d86a98d252ec6e078dd0

See more details on using hashes here.

File details

Details for the file dur_converter-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: dur_converter-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for dur_converter-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f1dfaf55d42dc760963c1a3bcd19720e1441a2c6392232d3ab4c427d01b25ccd
MD5 683b6220d7968b4484dfa4ff1b478a4f
BLAKE2b-256 f3b425f5316e57abd52b34874322fd7ef8424630fda5bdc38b8a4c1ce9fa44f2

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