Skip to content

Commit

Permalink
FFtools 1.0.0 release
Browse files Browse the repository at this point in the history
First FFtools release
  • Loading branch information
gatomod committed Mar 21, 2023
1 parent e3df51d commit 2632329
Show file tree
Hide file tree
Showing 34 changed files with 861 additions and 361 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: paypal.me/gatomooficial
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Cargo.lock
/target
/backups
/tests
/build
15 changes: 13 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
[package]
name = "fftools"
version = "1.0.0"
description = "FFMPEG-based toolkit for easy media manipulation"
license = "Apache-2.0"
authors = ["Gátomo"]
readme = "README.md"
homepage = "https://github.com/gatomo-oficial/fftools"
repository = "https://github.com/gatomo-oficial/fftools"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[package.metadata]
depends = ["ffmpeg"]

[package.metadata.deb]
depends = "ffmpeg"

[dependencies]
colored = "2.0.0"
indoc = "2.0.0"
pico-args = "0.5.0"
pico-args = {version = "0.5.0", features = ["eq-separator", "short-space-opt", "combined-flags"]}
tabled = "0.10.0"
113 changes: 112 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,114 @@
<img align="left" width="150" height="150" src="assets/FFtools.png">

# FFtools
🔨 FFmpeg-based toolkit for manipulate multimedia easily
## FFMPEG-based toolkit for easy media manipulation

<br />

[<img alt="license" src="https://img.shields.io/github/license/gatomo-oficial/path_trav.svg?color=06b6d4&style=for-the-badge&logo=Apache">](https://www.apache.org/licenses/LICENSE-2.0)
[<img alt="crates.io" src="https://img.shields.io/crates/v/fftools.svg?style=for-the-badge&color=fc8d62&logo=rust">](https://crates.io/crates/path_trav)
[<img alt="discord" src="https://img.shields.io/discord/880947411432923136?style=for-the-badge&color=blue&logo=discord">](https://gatomo.ga/discord)

FFtools is a FFmpeg command spawner made in Rust that focuses on simplicity in different common tasks (such as trim, optimize, merge, etc.).

In addition, it has several improvements, like automatic stream copy detection (which allows a faster coding) or media optimization via TBN (which can reduce file size with not much loss of quality).


## Table of contents
- [Usage example](#usage-example)
- [Wiki](#wiki)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [Standalone (Using Cargo)](#standalone-using-cargo)
- [Linux](#linux)
- [Arch Linux](#arch-linux)
- [Debian/Ubuntu](#debianubuntu)
- [Windows](#windows)
- [Manual](#manual)
- [Manual](#manual-1)
- [Development](#development)
- [Release history](#release-history)
- [License](#license)
- [Contribute](#contribute)

## Usage example


Convert to lossless GIF
```sh
fftools gif -i video.mp4 output.gif
```
https://user-images.githubusercontent.com/63877602/226492973-1edf7625-8301-4be0-a62d-c3146c655b30.mp4

Optimizing video at 5k TBN
```sh
fftools optimize -i video.mp4 output.mp4 5k
```
https://user-images.githubusercontent.com/63877602/226492359-b3155939-99e5-4f76-9bd2-7c4fa3d51238.mp4

You can use flags to extend command functionalities. All commands and arguments are available in the [FFtools Wiki](https://github.com/gatomo-oficial/fftools/wiki).

## Wiki
If you want to see an extended documentation about commands, options and usage, please go to [FFtools Wiki](https://github.com/gatomo-oficial/fftools/wiki).

## Installation
### Dependencies
- [`ffmpeg`](https://ffmpeg.org/)

### Standalone (Using Cargo)
```sh
cargo install fftools
```

### Linux
#### Arch Linux
FFtools is available via AUR.
```sh
yay -S fftools-bin
# or
paru -S fftools-bin
```

#### Debian/Ubuntu
For Debian, Ubuntu and Debian-based distros, download the `.deb` in [`Releases`](https://github.com/gatomo-oficial/fftools/releases/). Then install it with DPKG.
```sh
sudo dpkg -i fftools_1.0.0_amd64.deb
```

### Windows
FFtools is also available on Windows.

#### Manual
1. Install `FFmpeg`.
2. Download the .exe in [`Releases`](https://github.com/gatomo-oficial/fftools/releases/).
3. Add it to PATH. If you don't know how to do it, [read this post](https://www.architectryan.com/2018/03/17/add-to-the-path-on-windows-10/).

> **Note:** There will be Scoop support soon...
### Manual
If you want to edit code or install it manually you can run these commands.
```sh
git clone https://github.com/gatomo-oficial/fftools.git
cd fftools
cargo build --release
```

## Development
Clone the repository, install dependencies and run it.
```sh
git clone https://github.com/gatomo-oficial/fftools.git
cd fftools
cargo run
```

## Release history
* 1.0.0
* Initial release

## License
FFtools is licensed under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0).

## Contribute
Any PR is welcome! Is a small project, so the guideline is to follow the code style and not make insane purposes.

*Gátomo - Apache 2.0 license*
Binary file added assets/FFtools.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/showcase-gif.mp4
Binary file not shown.
Binary file added assets/showcase-optimize.mp4
Binary file not shown.
20 changes: 20 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# this script is weird

cargo install cargo-aur cargo-deb

cargo aur
cargo deb

mkdir -p build

mv target/debian/* build
mv *.tar.gz build

makepkg --printsrcinfo > .SRCINFO

mv PKGBUILD build
mv .SRCINFO build

cargo build --target x86_64-pc-windows-gnu --release
mv target/x86_64-pc-windows-gnu/release/fftools.exe build/fftools-windows-x86_64.exe
190 changes: 132 additions & 58 deletions src/logs.rs
Original file line number Diff line number Diff line change
@@ -1,66 +1,123 @@
use colored::*;
use indoc::printdoc;
use tabled::Style;
use tabled::TableIteratorExt;
use tabled::{format::Format, object::Columns, Modify};

const HELP: &str = "Use `--help` for more information.";

fn parse_table(input: &[[&str; 2]]) -> String {
input
.table()
.with(Style::blank())
.with(Modify::new(Columns::single(0)).with(Format::new(|s| s.bold().yellow().to_string())))
.to_string()
.lines()
.skip(1)
.map(|e| e)
.collect::<Vec<&str>>()
.join("\n ")
}

/// ## Help
/// Help string with command list.
// TODO add help generator
pub fn help() {
printdoc! {
"{title}
FFmpeg-based toolkit for manipulate multimedia easily
Copyright 2023 Gátomo
Licensed under the Apache License, Version 2.0
< https://www.apache.org/licenses/LICENSE-2.0 >
{usage}
fftools <SUBCOMMAND> -i <INPUT> [OPTIONS] <OUTPUT>
{commands}
trim Trims video between a range [ at least `--from` or `--to` ]
gif Converts video into lossless GIF [ no options ]
scale Scale a file by percentage [ `--scale` ]
volume Set audio volume [ `--volume` ]
free Dynamic subcommand [ any option ]
{options}
IO management:
-i, --input <file> Input file
-w, --overwrite Overwrite output
Media manipulation:
-f, --from <time> Start timestamp
-t, --to <time> End timestamp
-s, --scale <percentage> Scale percentage
--fps <fps> Set framerate
-vv, --volume <level> Set volume (dB or percentage)
Miscellaneous:
-V, --verbose Add verbosity
-h, --help Show this message
-v, --version Show FFtools version
\n",
title="<< FFtools >>".cyan().bold(),
usage="USAGE".bold(),
commands="COMMANDS".bold(),
options="OPTIONS/FLAGS".bold(),
};
/* println!(
r#"{}
{}
FFmpeg-based toolkit for manipulate multimedia easily.
Licensed under the Apache License, Version 2.0.
< https://www.apache.org/licenses/LICENSE-2.0 >"#,
"<< FFtools >>".cyan().bold(),
format!(
"Version {} - Copyright 2023 Gátomo",
env!("CARGO_PKG_VERSION")
)
.italic()
) */
#[rustfmt::skip]
let cmd_table = [
["o, optimize", "Reduce input TBN to reduce file size with not much loss of quality"],
["t, trim", "Trims media between a range"],
["g, gif", "Converts video into lossless GIF"],
["s, scale", "Scale a file by percentage"],
["v, volume", "Set audio volume"],
["m, merge", "Merge audio and video"],
[" fps", "Set framerate"],
["f, free", "Dynamic subcommand"],
];

#[rustfmt::skip]
let io_table = [
["-i, --input <file>", "Input file"],
["-w, --overwrite", "Overwrite output"],
];

#[rustfmt::skip]
let manipulation_table = [
["-f, --from <time>", "Start timestamp"],
["-t, --to <time>", "End timestamp"],
["-s, --scale <percent>", "Scale percentage"],
[" --fps <fps>", "Set framerate"],
["-l, --volume <level>", "Set volume (dB or percentage)"],
["-n, --noaudio", "Silent media"],
[" --notrim", "Avoid media trimming (useful for `trim` command)",],
];

#[rustfmt::skip]
let encode_table = [
["-o, --optimize", "Reduces TBN"],
["-e, --encode", "Encode input stream to output format"],
[" --vencode", "Encode video"],
[" --aencode", "Encode audio"],
["-c, --copy", "Copy input stream to output (no encode)"],
[" --vcopy", "Copy video"],
[" --acopy", "Copy audio"],
];

#[rustfmt::skip]
let misc_table = [
["-V, --verbose", "Add verbosity"],
["-h, --help", "Show this message"],
["-v, --version", "Show FFtools version"],
];

println!(
r#"{title}
FFMPEG-based toolkit for easy media manipulation
Copyright 2023 Gátomo
Licensed under the Apache License, Version 2.0
{apache}
{usage}
{usage_struct}
{commands}
{commands_table}
{options}
{io}
{io_table}
{manipulation}
{manipulation_table}
{encode}
{encode_table}
{misc}
{misc_table}
{doc_title}
See GitHub Wiki for detailed description of commands and options.
{wiki}
"#,
title = "<< FFtools >>".cyan().bold(),
apache = "< https://www.apache.org/licenses/LICENSE-2.0 >".italic(),
usage = "USAGE".green().bold(),
usage_struct = "fftools <SUBCOMMAND> -i <INPUT> [OPTIONS] <OUTPUT> [SUB_VALUES]".bold(),
commands = "COMMANDS".green().bold(),
commands_table = parse_table(&cmd_table),
options = "OPTIONS/FLAGS".green().bold(),
io = "IO management:".bold(),
io_table = parse_table(&io_table),
manipulation = "Media manipulation:".bold(),
manipulation_table = parse_table(&manipulation_table),
encode = "Media codification:".bold(),
encode_table = parse_table(&encode_table),
misc = "Miscellaneous:".bold(),
misc_table = parse_table(&misc_table),
doc_title = "Something is missing?".cyan().bold(),
wiki = "< https://github.com/gatomo-oficial/fftools/wiki >".italic()
);
}

pub fn version() {
Expand Down Expand Up @@ -90,9 +147,9 @@ pub fn error(msg: String, tip: Option<String>) {
)
}

/// ## ferror
/// ## flag_error
/// Prints a list of missing flags.
pub fn ferror(cmd: String, flags: Vec<&str>, min: Option<u8>) {
pub fn flag_error(cmd: &str, flags: Vec<&str>, min: Option<&str>) {
eprintln!(
"{} `{}` command requires{} the next flags:\n{}\n\n{}",
"Error >".red().bold(),
Expand All @@ -107,6 +164,23 @@ pub fn ferror(cmd: String, flags: Vec<&str>, min: Option<u8>) {
)
}

/// ## args_error
/// Prints a list of missing args.
pub fn args_error(cmd: &str) {
eprintln!(
"{} `{}` command requires a value\n{}",
"Error >".red().bold(),
cmd,
HELP.italic()
)
}

/// ## nan_error
/// Prints a NaN error
pub fn nan_error() {
error("Please insert a valid number.".into(), None);
}

/// ## Warn
/// Prints a warn.
pub fn warn(msg: String) {
Expand Down
Loading

0 comments on commit 2632329

Please sign in to comment.