Coder Social home page Coder Social logo

termplay's Introduction

termplay

Name by the awesome @tbodt

Are you a terminal fanboy like me?
Sure, but do you ever watch YouTube? In your terminal?


termplay is the tool to convert images to ANSI sequences.
But it also supports playing videos...
Written in the systems language Rust, it has some solid performance.

  • Multiple modes
    • Sixels: Only supported by a few terminals, like xterm.
    • Unicode halfblock: This is the same as TrueColor below, but uses unicode half-blocks for smaller pixels.
    • TrueColor: Any RGB color, supported by most terminals.
    • 256 color: The closest representation of a color that can be fit within 1 byte. Use this if nothing else works.
  • Flexible
    • Change framerate, size and more using command line switches
  • Adapting size
    • Automatically scales the image to fit your terminal

Termplay also allows you to control the media, such as zoom in or pause the video.

  • Mouse Scroll / +/-: Zoom
  • Mouse Drag / W/A/S/D: Pan
  • Space: Play/Pause
  • Left/Right: Seek
  • Up/Down: Volume
  • q / Ctrl+C: Quit

Example image
(Landscape image from pexels.com)

Using

Image

termplay 2.0.0
jD91mZM2 <[email protected]>
Play images/videos in your terminal

USAGE:
    termplay [FLAGS] [OPTIONS] <path>

FLAGS:
        --help       Prints help information
    -q, --quiet      Ignores all the nice TUI things for simple image viewing
    -V, --version    Prints version information

OPTIONS:
    -c, --converter <converter>    Decides how the image should be displayed [default: halfblock]  [possible values:
                                   color256, halfblock, sixel, truecolor]
    -h, --height <height>          Sets the height (defaults to the terminal size, or 24)
    -r, --rate <rate>              Sets the framerate [default: 24]
        --ratio <ratio>            Sets the terminal font ratio (only takes effect with some converters)
    -w, --width <width>            Sets the width (defaults to the terminal size, or 80)

ARGS:
    <path>    Specifies the path to the image/video to play

Compiling

Compile time requirements

Rust v1.25 or more is required. See your Rust version with

rustc --version

Update rust with

rustup update stable

Compiling!

Other than that, this project is hosted on crates.io.
So to install you just need to run

cargo install termplay --features bin

(Note: The --features part is a hack because binaries don't allow specifying separate dependencies)

Features

Almost all dependencies are optional and can be disabled!

Default features:

  • termion: This is what enables the rich image viewer. Disabling this will disable almost everything.
  • gst: Video support, requires gstreamer
  • sixel: Support for sixels, requires libsixel

To disable default features, run

cargo install termplay --no-default-features --features "bin,..."

where ... is a comma separated list of features you want to keep.

Nix

Termplay is available with the default features on Nix!

nix-env -iA nixpkgs.termplay

Arch Linux

If you just want to get this running on Arch Linux with the default features, you can use the
AUR Package (unofficial)

Debian / Ubuntu

Example:

sudo apt install libopenal-dev libsndfile1-dev libsixel-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev
cargo install termplay --features bin

termplay's People

Contributors

baryluk avatar jd91mzm2 avatar sdroege avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

termplay's Issues

Failed to write the file

Checking ffmpeg... SUCCESS

Creating directory...
Starting conversion: Video -> Image...
Started new process.
Converting: Image -> Text
Processing frame1.pngFailed to write to file: No space left on device (os error 28)

Can't Build

Hi,

I followed and Installed the required Libraries as you mentioned in README.md,
apt install libopenal-dev libsndfile1-dev libgstreamer1.0-dev libsixel-dev

but I get this:

error: failed to run custom build command for gstreamer-app-sys v0.5.0process didn't exit successfully:/tmp/cargo-install.UHVy5JJj1usQ/release/build/gstreamer-app-sys-9fd3835cd27cf2c1/build-script-build(exit code: 1) --- stderr"pkg-config" "--libs" "--cflags" "gstreamer-app-1.0 >= 1.8"did not exit successfully: exit code: 1 --- stderr Package gstreamer-app-1.0 was not found in the pkg-config search path. Perhaps you should add the directory containinggstreamer-app-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gstreamer-app-1.0' found

warning: build failed, waiting for other jobs to finish...
error: failed to compile termplay v2.0.2, intermediate artifacts can be found at /tmp/cargo-install.UHVy5JJj1usQ

My RustC version is rustc 1.24.1

Update install instructions

Hello guy,
I tried compiling this project with cargo. Your install instruction just tells cargo build --release, because you probably don't realise you use some shared libraries already present on your system. Anyway, that's what I got on Fedora 25:

 = note: /usr/bin/ld: cannot find -lopenal
/usr/bin/ld: cannot find -lsndfile
collect2: error: ld returned 1 exit statu

sane escape codes

like alternate screen mode and hide cursor during playback, and reset cursor to top left before each frame

why did I have to explain that you're psychic and you just know

Doesn't build

I can't build termplay.
I tried cargo install termplay, I tried cloning and cargo run, I tried cargo build --release.

The output ends like that:

error: use of unstable library feature 'process_try_wait' (see issue #38903)
   --> src/preprocess.rs:102:17
    |
102 | 			match ffmpeg.try_wait() {
    | 			             ^^^^^^^^
...
150 | 				wait_for_ffmpeg!(err);
    | 			 ---------------------- in this macro invocation

error: use of unstable library feature 'process_try_wait' (see issue #38903)
   --> src/preprocess.rs:102:17
    |
102 | 			match ffmpeg.try_wait() {
    | 			             ^^^^^^^^
...
162 | 				wait_for_ffmpeg!(err);
    | 			 ---------------------- in this macro invocation

error: aborting due to 2 previous errors

error: Could not compile `termplay`.

To learn more, run the command again with --verbose.
cargo build --release  341,48s user 6,89s system 226% cpu 2:33,69 total
% rustc --version
rustc 1.17.0

Failed. Retrying

Creating directory...
Starting conversion: Video -> Image...
Started new process.
Converting: Image -> Text
Processing frame1.png
Failed. Retrying...
Processing frame1.png
Failed. Retrying...
Processing frame1.png
Failed. Retrying...
Processing frame1.png
I have tried 3 times, still can't read the file.
Did ffmpeg hang? Are you trolling me by deleting files?
I give up. Error: Format error: unexpected EOF

Build fails

Hi.

Just tried to build termplay on my machine.
Here's what I get

error: this needs a `'static` lifetime or the `static_in_const` feature, see #35897
  --> /home/antouank/.cargo/registry/src/github.com-1ecc6299db9ec823/sixel-sys-0.2.0/build.rs:13:21
   |
13 | const LIBSIXEL_DIR: &str = "libsixel";
   |                     ^^^^

error: this needs a `'static` lifetime or the `static_in_const` feature, see #35897
  --> /home/antouank/.cargo/registry/src/github.com-1ecc6299db9ec823/sixel-sys-0.2.0/build.rs:98:23
   |
98 | const FEATURE_PREFIX: &str = "CARGO_FEATURE_";
   |                       ^^^^

error: aborting due to 2 previous errors

Build failed, waiting for other jobs to finish...
error: failed to compile `termplay v1.0.0`, intermediate artifacts can be found at `/tmp/cargo-install.KfttQRX1ag1K`

Caused by:
  Could not compile `sixel-sys`.

To learn more, run the command again with --verbose.

the commands I run

10146  git clone [email protected]:legolord208/termplay.git
10147  cd termplay
10148  rustc --version
10149  rustup update stable
10150  cargo install termplay

info ( if needed )

~/_REPOS_/termplay master
❯ uname -ar             
Linux i7 4.11.6-1-ARCH #1 SMP PREEMPT Sat Jun 17 08:19:42 CEST 2017 x86_64 GNU/Linux

~/_REPOS_/termplay master
❯ rustc --version     
rustc 1.16.0-nightly (6f1ae663e 2017-01-06)

Feature request: double vertical resolution using unicode half blocks

It would be nice to have double the vertical resolution by using either ▀ (U+2580, Upper half block) or ▄ (U+2584, Lower half block) in combination with both settion fore- and background color.

For example, sending \e[48;5;9m\e38;5;10m▄ to the terminal will show the upper half red and the lower half green.

Additionally, those half blocks are usually much closer to a square than a space is.

Naively one would do something along the lines of:

if y%2 == 0 {
        for x in 0..image.width() {
                let pixel = image.get_pixel(x, y);
                let lower_pixel = image.get_pixel(x, y+1);
                let channels = pixel.channels();
                let lower_channels = lower_pixel.channels();
                use std::fmt::Write;
                write!(result, "\x1b[48;2;{};{};{}m\x1b[38;2;{};{};{}m▄", 
                        channels[0], channels[1], channels[2], 
                        lower_channels[0], lower_channels[1], lower_channels[2]).unwrap();
        }
}

However, this will fail if the height of the input is an uneven number of pixels, since it will try to read out of bonds.

Sadly, I don't actually know Rust and have no idea, how to fix this 😒

Installation error : unreachable pattern

Hi,

It's my first time install termplay and got this error

error[E0001]: unreachable pattern --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/image-0.14.0/./src/dynimage.rs:641:9 | 641 | _ => Err(image::ImageError::UnsupportedError(format!("A decoder for {:?} is not available.", format))), | ^ this is an unreachable pattern

Any missing there?
Need help please

Process video frames to text in real-time

It would be nice if the video frames could be processed to text in real-time without having the tool process all of them at initialization causing a lot of wait with long videos.

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.