/terminal_viewer

A terminal application that brings images 🖼️ and videos 🎥 to life directly in your terminal! Display visuals in pixelated color mode, offering a unique and nostalgic experience. Perfect for developers who love working in the terminal! 🚀

Primary LanguagePython

terminal_viewer 🎥

terminal_viewer is a simple command line application designed to display media files directly in the terminal. It leverages OpenCV for handling image files and PyAV for video files, ensuring compatibility with a wide range of media formats supported by these libraries. This tool is ideal for users who prefer working within the terminal environment and need a quick way to preview media files without leaving the command line.

Features

  • 🖼️ Image and Video Support: Display both images and videos in the terminal.
  • 🎨 Grayscale Option: View media files in grayscale with a simple flag.
  • Lightweight and Fast: Optimized for quick previews and minimal resource usage.
  • 🛠️ Customizable: Easily specify multiple files or folders to display.
  • 💻 Terminal-Friendly: Ideal for users who prefer working within the terminal environment.

Installation

  1. Clone the repository:
    git clone https://github.com/Armaggheddon/terminal_viewer.git
    cd terminal_viewer
  2. Install the required dependencies
    pip install -r requirements.txt
  3. Build the python wheel:
    python .\setup.py sdist bdist_wheel
  4. Depending on your os:
    # for windows
    pip install .\dist\terminal_viewer-0.1-py3-none-any.whl
    
    # for MacOS/Linux
    pip install .\dist\terminal_viewer-0.1.tar.gz
    If the tool is already installed run the above command with --force-reinstall option.
  5. Launch the application with:
    terminal_viewer --help

Usage

The application supports the following arguments:

  • -s, --source: specifies a single media file to be opened. Multiple files can be specified using a space as a separator between paths.
  • -f, --folder: specifies a single folder that can contain 1 or more media files to be displayed. Multiple folders can be specified using a space as a separator between paths.
  • -g, --grayscale: display the media files in grayscale. By default all the media files are shown in RGB 256.
  • -h, --help: show the available commands with a brief description.

Once the application is launched the following keys can be used to perform specific actions:

  • q: quits the application.
  • r: rewinds the current video being played. Works only on videos.
  • m: goes to the next media if any, or terminates the application if the current media is the last one.
  • n: goes to the previous media if any, if the current media is the first one behaves like a rewind command.
  • +: goes to the next keyframe. Works only on videos.
  • -: goes to the previous keyframe. Works only on videos.
  • p: play/pause the current media. Works only on videos.
  • t: hides/shows an overlay with the media file name, the current position in the queue of items to be played and, if the media file is a video, the progress bar with the media duration.
  • h: hides/shows an onverlay with all of the above commands.
unsupported media
Unsupported media
display image
Displaying an image
unsupported media
Displaying a video
display grayscale
Displaying media with grayscale

Examples

The following examples show how to use the application.

  • Display a single image:
    terminal_viewer -s path/to/image.jpg
  • Display a single video:
    terminal_viewer -s path/to/video.mp4
  • Display a single image in grayscale:
    terminal_viewer -s path/to/image.jpg -g
  • Display all the media files in a folder:
    terminal_viewer -f path/to/folder

Dependencies