Skip to content

Commit 2632329

Browse files
committed
FFtools 1.0.0 release
First FFtools release
1 parent e3df51d commit 2632329

34 files changed

+861
-361
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: paypal.me/gatomooficial

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ Cargo.lock
22
/target
33
/backups
44
/tests
5+
/build

Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
[package]
22
name = "fftools"
33
version = "1.0.0"
4+
description = "FFMPEG-based toolkit for easy media manipulation"
5+
license = "Apache-2.0"
6+
authors = ["Gátomo"]
7+
readme = "README.md"
8+
homepage = "https://github.com/gatomo-oficial/fftools"
9+
repository = "https://github.com/gatomo-oficial/fftools"
410
edition = "2021"
511

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
12+
[package.metadata]
13+
depends = ["ffmpeg"]
14+
15+
[package.metadata.deb]
16+
depends = "ffmpeg"
717

818
[dependencies]
919
colored = "2.0.0"
1020
indoc = "2.0.0"
11-
pico-args = "0.5.0"
21+
pico-args = {version = "0.5.0", features = ["eq-separator", "short-space-opt", "combined-flags"]}
22+
tabled = "0.10.0"

README.md

Lines changed: 112 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,114 @@
1+
<img align="left" width="150" height="150" src="assets/FFtools.png">
2+
13
# FFtools
2-
🔨 FFmpeg-based toolkit for manipulate multimedia easily
4+
## FFMPEG-based toolkit for easy media manipulation
5+
6+
<br />
7+
8+
[<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)
9+
[<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)
10+
[<img alt="discord" src="https://img.shields.io/discord/880947411432923136?style=for-the-badge&color=blue&logo=discord">](https://gatomo.ga/discord)
11+
12+
FFtools is a FFmpeg command spawner made in Rust that focuses on simplicity in different common tasks (such as trim, optimize, merge, etc.).
13+
14+
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).
15+
16+
17+
## Table of contents
18+
- [Usage example](#usage-example)
19+
- [Wiki](#wiki)
20+
- [Installation](#installation)
21+
- [Dependencies](#dependencies)
22+
- [Standalone (Using Cargo)](#standalone-using-cargo)
23+
- [Linux](#linux)
24+
- [Arch Linux](#arch-linux)
25+
- [Debian/Ubuntu](#debianubuntu)
26+
- [Windows](#windows)
27+
- [Manual](#manual)
28+
- [Manual](#manual-1)
29+
- [Development](#development)
30+
- [Release history](#release-history)
31+
- [License](#license)
32+
- [Contribute](#contribute)
33+
34+
## Usage example
35+
36+
37+
Convert to lossless GIF
38+
```sh
39+
fftools gif -i video.mp4 output.gif
40+
```
41+
https://user-images.githubusercontent.com/63877602/226492973-1edf7625-8301-4be0-a62d-c3146c655b30.mp4
42+
43+
Optimizing video at 5k TBN
44+
```sh
45+
fftools optimize -i video.mp4 output.mp4 5k
46+
```
47+
https://user-images.githubusercontent.com/63877602/226492359-b3155939-99e5-4f76-9bd2-7c4fa3d51238.mp4
48+
49+
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).
50+
51+
## Wiki
52+
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).
53+
54+
## Installation
55+
### Dependencies
56+
- [`ffmpeg`](https://ffmpeg.org/)
57+
58+
### Standalone (Using Cargo)
59+
```sh
60+
cargo install fftools
61+
```
62+
63+
### Linux
64+
#### Arch Linux
65+
FFtools is available via AUR.
66+
```sh
67+
yay -S fftools-bin
68+
# or
69+
paru -S fftools-bin
70+
```
71+
72+
#### Debian/Ubuntu
73+
For Debian, Ubuntu and Debian-based distros, download the `.deb` in [`Releases`](https://github.com/gatomo-oficial/fftools/releases/). Then install it with DPKG.
74+
```sh
75+
sudo dpkg -i fftools_1.0.0_amd64.deb
76+
```
77+
78+
### Windows
79+
FFtools is also available on Windows.
80+
81+
#### Manual
82+
1. Install `FFmpeg`.
83+
2. Download the .exe in [`Releases`](https://github.com/gatomo-oficial/fftools/releases/).
84+
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/).
85+
86+
> **Note:** There will be Scoop support soon...
87+
88+
### Manual
89+
If you want to edit code or install it manually you can run these commands.
90+
```sh
91+
git clone https://github.com/gatomo-oficial/fftools.git
92+
cd fftools
93+
cargo build --release
94+
```
95+
96+
## Development
97+
Clone the repository, install dependencies and run it.
98+
```sh
99+
git clone https://github.com/gatomo-oficial/fftools.git
100+
cd fftools
101+
cargo run
102+
```
103+
104+
## Release history
105+
* 1.0.0
106+
* Initial release
107+
108+
## License
109+
FFtools is licensed under the [Apache 2.0 license](https://www.apache.org/licenses/LICENSE-2.0).
110+
111+
## Contribute
112+
Any PR is welcome! Is a small project, so the guideline is to follow the code style and not make insane purposes.
3113

114+
*Gátomo - Apache 2.0 license*

assets/FFtools.png

600 KB
Loading

assets/showcase-gif.mp4

927 KB
Binary file not shown.

assets/showcase-optimize.mp4

797 KB
Binary file not shown.

build.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# this script is weird
3+
4+
cargo install cargo-aur cargo-deb
5+
6+
cargo aur
7+
cargo deb
8+
9+
mkdir -p build
10+
11+
mv target/debian/* build
12+
mv *.tar.gz build
13+
14+
makepkg --printsrcinfo > .SRCINFO
15+
16+
mv PKGBUILD build
17+
mv .SRCINFO build
18+
19+
cargo build --target x86_64-pc-windows-gnu --release
20+
mv target/x86_64-pc-windows-gnu/release/fftools.exe build/fftools-windows-x86_64.exe

src/logs.rs

Lines changed: 132 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,123 @@
11
use colored::*;
2-
use indoc::printdoc;
2+
use tabled::Style;
3+
use tabled::TableIteratorExt;
4+
use tabled::{format::Format, object::Columns, Modify};
35

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

8+
fn parse_table(input: &[[&str; 2]]) -> String {
9+
input
10+
.table()
11+
.with(Style::blank())
12+
.with(Modify::new(Columns::single(0)).with(Format::new(|s| s.bold().yellow().to_string())))
13+
.to_string()
14+
.lines()
15+
.skip(1)
16+
.map(|e| e)
17+
.collect::<Vec<&str>>()
18+
.join("\n ")
19+
}
20+
621
/// ## Help
722
/// Help string with command list.
23+
// TODO add help generator
824
pub fn help() {
9-
printdoc! {
10-
"{title}
11-
FFmpeg-based toolkit for manipulate multimedia easily
12-
13-
Copyright 2023 Gátomo
14-
Licensed under the Apache License, Version 2.0
15-
< https://www.apache.org/licenses/LICENSE-2.0 >
16-
17-
{usage}
18-
fftools <SUBCOMMAND> -i <INPUT> [OPTIONS] <OUTPUT>
19-
20-
{commands}
21-
trim Trims video between a range [ at least `--from` or `--to` ]
22-
gif Converts video into lossless GIF [ no options ]
23-
scale Scale a file by percentage [ `--scale` ]
24-
volume Set audio volume [ `--volume` ]
25-
free Dynamic subcommand [ any option ]
26-
27-
28-
{options}
29-
IO management:
30-
-i, --input <file> Input file
31-
-w, --overwrite Overwrite output
32-
33-
Media manipulation:
34-
-f, --from <time> Start timestamp
35-
-t, --to <time> End timestamp
36-
-s, --scale <percentage> Scale percentage
37-
--fps <fps> Set framerate
38-
-vv, --volume <level> Set volume (dB or percentage)
39-
40-
Miscellaneous:
41-
-V, --verbose Add verbosity
42-
-h, --help Show this message
43-
-v, --version Show FFtools version
44-
\n",
45-
title="<< FFtools >>".cyan().bold(),
46-
usage="USAGE".bold(),
47-
commands="COMMANDS".bold(),
48-
options="OPTIONS/FLAGS".bold(),
49-
};
50-
/* println!(
51-
r#"{}
52-
{}
53-
FFmpeg-based toolkit for manipulate multimedia easily.
54-
Licensed under the Apache License, Version 2.0.
55-
56-
< https://www.apache.org/licenses/LICENSE-2.0 >"#,
57-
"<< FFtools >>".cyan().bold(),
58-
format!(
59-
"Version {} - Copyright 2023 Gátomo",
60-
env!("CARGO_PKG_VERSION")
61-
)
62-
.italic()
63-
) */
25+
#[rustfmt::skip]
26+
let cmd_table = [
27+
["o, optimize", "Reduce input TBN to reduce file size with not much loss of quality"],
28+
["t, trim", "Trims media between a range"],
29+
["g, gif", "Converts video into lossless GIF"],
30+
["s, scale", "Scale a file by percentage"],
31+
["v, volume", "Set audio volume"],
32+
["m, merge", "Merge audio and video"],
33+
[" fps", "Set framerate"],
34+
["f, free", "Dynamic subcommand"],
35+
];
36+
37+
#[rustfmt::skip]
38+
let io_table = [
39+
["-i, --input <file>", "Input file"],
40+
["-w, --overwrite", "Overwrite output"],
41+
];
42+
43+
#[rustfmt::skip]
44+
let manipulation_table = [
45+
["-f, --from <time>", "Start timestamp"],
46+
["-t, --to <time>", "End timestamp"],
47+
["-s, --scale <percent>", "Scale percentage"],
48+
[" --fps <fps>", "Set framerate"],
49+
["-l, --volume <level>", "Set volume (dB or percentage)"],
50+
["-n, --noaudio", "Silent media"],
51+
[" --notrim", "Avoid media trimming (useful for `trim` command)",],
52+
];
53+
54+
#[rustfmt::skip]
55+
let encode_table = [
56+
["-o, --optimize", "Reduces TBN"],
57+
["-e, --encode", "Encode input stream to output format"],
58+
[" --vencode", "Encode video"],
59+
[" --aencode", "Encode audio"],
60+
["-c, --copy", "Copy input stream to output (no encode)"],
61+
[" --vcopy", "Copy video"],
62+
[" --acopy", "Copy audio"],
63+
];
64+
65+
#[rustfmt::skip]
66+
let misc_table = [
67+
["-V, --verbose", "Add verbosity"],
68+
["-h, --help", "Show this message"],
69+
["-v, --version", "Show FFtools version"],
70+
];
71+
72+
println!(
73+
r#"{title}
74+
FFMPEG-based toolkit for easy media manipulation
75+
76+
Copyright 2023 Gátomo
77+
Licensed under the Apache License, Version 2.0
78+
{apache}
79+
80+
{usage}
81+
{usage_struct}
82+
83+
{commands}
84+
{commands_table}
85+
86+
{options}
87+
{io}
88+
{io_table}
89+
90+
{manipulation}
91+
{manipulation_table}
92+
93+
{encode}
94+
{encode_table}
95+
96+
{misc}
97+
{misc_table}
98+
99+
{doc_title}
100+
See GitHub Wiki for detailed description of commands and options.
101+
{wiki}
102+
"#,
103+
title = "<< FFtools >>".cyan().bold(),
104+
apache = "< https://www.apache.org/licenses/LICENSE-2.0 >".italic(),
105+
usage = "USAGE".green().bold(),
106+
usage_struct = "fftools <SUBCOMMAND> -i <INPUT> [OPTIONS] <OUTPUT> [SUB_VALUES]".bold(),
107+
commands = "COMMANDS".green().bold(),
108+
commands_table = parse_table(&cmd_table),
109+
options = "OPTIONS/FLAGS".green().bold(),
110+
io = "IO management:".bold(),
111+
io_table = parse_table(&io_table),
112+
manipulation = "Media manipulation:".bold(),
113+
manipulation_table = parse_table(&manipulation_table),
114+
encode = "Media codification:".bold(),
115+
encode_table = parse_table(&encode_table),
116+
misc = "Miscellaneous:".bold(),
117+
misc_table = parse_table(&misc_table),
118+
doc_title = "Something is missing?".cyan().bold(),
119+
wiki = "< https://github.com/gatomo-oficial/fftools/wiki >".italic()
120+
);
64121
}
65122

66123
pub fn version() {
@@ -90,9 +147,9 @@ pub fn error(msg: String, tip: Option<String>) {
90147
)
91148
}
92149

93-
/// ## ferror
150+
/// ## flag_error
94151
/// Prints a list of missing flags.
95-
pub fn ferror(cmd: String, flags: Vec<&str>, min: Option<u8>) {
152+
pub fn flag_error(cmd: &str, flags: Vec<&str>, min: Option<&str>) {
96153
eprintln!(
97154
"{} `{}` command requires{} the next flags:\n{}\n\n{}",
98155
"Error >".red().bold(),
@@ -107,6 +164,23 @@ pub fn ferror(cmd: String, flags: Vec<&str>, min: Option<u8>) {
107164
)
108165
}
109166

167+
/// ## args_error
168+
/// Prints a list of missing args.
169+
pub fn args_error(cmd: &str) {
170+
eprintln!(
171+
"{} `{}` command requires a value\n{}",
172+
"Error >".red().bold(),
173+
cmd,
174+
HELP.italic()
175+
)
176+
}
177+
178+
/// ## nan_error
179+
/// Prints a NaN error
180+
pub fn nan_error() {
181+
error("Please insert a valid number.".into(), None);
182+
}
183+
110184
/// ## Warn
111185
/// Prints a warn.
112186
pub fn warn(msg: String) {

0 commit comments

Comments
 (0)