reticivis-net / mediaforge

A Discord bot for editing and creating videos, images, GIFs, and more!
GNU General Public License v3.0
81 stars 28 forks source link
bot discord discord-py ffmpeg fun gifs libvips meme python

MediaForge

MediaForge Discord uptime

Total Lines wakatime stars built with immense swag

ko-fi

A Discord bot for editing and creating videos, images, GIFs, and more!

general technical info about the bot

self-host with docker

to install

All you need to install yourself is Docker Desktop

as of writing, a working docker copy of MediaForge takes up ~3.46GB. if this is a concern and you are using some of the apt libraries MediaForge does, see to self-host natively

once that's installed, run these commands in your terminal of choice.

docker build -t melodyflorum/mediaforge https://github.com/reticivis-net/mediaforge.git
docker run -it --cap-add SYS_NICE --shm-size 8G --name mediaforge melodyflorum/mediaforge

on linux, you may need to run docker with sudo

replace 8G with how much free RAM your system has that you would like to give MediaForge (in gigabytes). At least 1G is suggested. Making this too small can make commands fail due to not enough space, as the /dev/shm in-memory filesystem is, by default, MediaForge's sole temporary directory. Override the override_temp_dir option in config.py if you can't allocate enough memory.

if the installation succeeded, you should be prompted with some options. you'll need to select "Edit Config". this will open a text editor within your terminal. the 2 required config settings to change for proper functionality are the discord and tenor tokens. be sure not to add or remove quotes. press CTRL+S to save and CTRL+X to exit.

if you don't want to use the built-in text editor, you can get the example config from GitHub, hold down CTRL+K to clear the file and then use CTRL+V to paste in your config.

to run

run in your favorite terminal:

docker start -ia mediaforge

by default, MediaForge will await user input for 10 seconds before attempting to run the bot automatically.

to stop

killing the terminal window/CTRL+C won't kill the bot, because docker runs in the background.

to kill the bot, run

docker stop mediaforge

to limit resource consumption

since docker is very containerized, you can easily limit the amount of resources it's allowed to consume.

the main command to do this is docker update, though most of these arguments can be passed verbatim to docker run during setup.

the most useful options are --memory and --cpus.

for example, this is (as of writing) what the official MediaForge bot uses:

docker update --memory 9000M --memory-swap -1 --cpus "3.9" mediaforge

Automode

this is designed to work with hosting providers where terminal control is not possible. There are 3 arguments to this mode that can be set as docker build arguments or environment variables . AUTOMODE: set to "ON" to enable automode AUTOUPDATE: set to "ON" to update code and packages every run CONFIG: base64 encoded version of your config file.

to encode base 64

on linux:
with python:
import base64

with open("config.py", "rb") as f:
    out = base64.b64encode(f.read())
print(out)  # write to terminal
# write to file
with open("config.txt", "wb+") as f:
    f.write(out)

to self-host natively

MediaForge is a complex application and manually installing all dependencies is a headache. for almost all use cases, the docker distribution is much better.

summary

ensure your OS is one of the supported OSes, then install the python libraries and the non-python libraries, set up the config, and run

supported OSes

built and tested on windows 10/11 and debian 10/buster (inside docker). these 2 OSes (and their successors) will continue to be officially supported.

will probably work on macos and other linux/unix distros if the below libraries are available but theyre untested and unsupported. just replace apt-get with your system's preferred package manager (brew for macos)

on Windows, color emojis won't work. no idea why, just is a windows pango bug.

python libraries

non-python libraries

the bot uses many external CLI programs for media processing.

config

python

to run

legal stuff

terms of service

privacy policy