Misc scripts

FFmpeg Logo

A bunch of small scripts/programs that accomplish various tasks.

# FFcompress

Compress videos to a desired size with just one command.

It only supports H.264 codec and MP4 container format, because those are universally supported on all platforms. It is better to use WebM for a better end result, but encoding WebM is so incredibly, incredibly slow that I decided to not support it at all.

The script supports hardware acceleration as well, but there's a high chance it won't work on hardware other than mine.

NAME:
 ffcompress - ffmpeg helper script for compressing a file to a desired file size.

USAGE:
  ffcompress [command options] [arguments...]

VERSION:
 0.0.1

OPTIONS:
   -y, --[no-]yes       false    Whether to overwrite the output file.
   -d, --[no-]dry       false    Just print what would've been done, not actually run it. Useful for testing.
   -i, --input S*                Input video file to compress.
   -s, --size N.N       9        Target size for the video in MB.
   -p, --preset S       medium   Preset to use for encoding the video.
       --m:a N          0        Audio track to use. More than one options merge audio tracks.
       --c:a S          libopus  Audio codec to use.
       --b:a N          128000   Audio bitrate for the output.
   -r, --fps N          60       Video framerate.
       --scale S        1280:-2  Video scale (resolution).
       --[no-]hw-accel           Hardware acceleration.
   -o, --output S*               Compressed video file output path.
   -?, --help

# FFmpeg Split Timestamps

Split audio mashup into individual songs according to supplied timestamps (includes title in the metadata).

Sample usage:

./ffmpeg-split-timestamps 'OLDER Electro Swing Collection.mp3' <<< "
0:00 All Night - Parov Stelar
2:43 Peeping Tom - Rosie Harte
6:13 Thrift Shop - (Bart & Baker Remix)
9:58 Mojo Radio Gang - Parov Stelar
12:38 It Don't Mean a Thing (If It Ain't That Swing) - Lionel Hampton
16:15 Dragons - Caravan Palace
20:27 Geraldine's Routine - Tape Five
23:32 Suzy - Caravan Palace
27:39 Delight - Jamie Berry
33:24 Cinnamon Girl (Club Edit) - dunkelbunt music
37:19 Rascal - Jamie Berry
41:28 Booty Swing - Parov Stelar
44:40 Libella Swing - Parov Stelar
49:01 Catgroove - Parov Stelar
53:30 Chambermaid Swing - Parov Stelar
59:15 Dirty Stop Out - Jamie Berry*
1:05:26 BeatBuddy Swing - Parov Stelar
1:09:44 Josephine - Parov Stelar
"

# Gifski Video

Allows converting any video file into a high-quality GIF.

This script is basically just glue between FFmpeg and Gifski with some temporary file management for ease of use. It's recommended you match FPS in both FFmpeg and Gifski so that it looks correct.

Usage:

gifski-video <FFMPEG-OPTS> --- <GIFSKI-OPTS>

# GPU Average Usage

Calculate average GPU usage given a file showing current GPU usage.

Why calculate average usage? GPU usage fluctuates very rapidly, and momentary info is not much useful for day-to-day usage. By taking an average of a small time span, you get a more "tame" metric that would otherwise look like chaos.

USAGE:
  gpu-average-usage [command options]

OPTIONS:
  -t  Whether to truncate the decimal part of the percentage. [default=false]
  -d  Sampling duration in seconds. [default=1]
  -s  Amount of samples to take. [default=10]
  -g  GPU usage file.
  -h  Print this help message.