Media Service
The small program that stores screenshots, videos, logs, statistics and backups next to FXServer.
The script starts a small program (media/bin/tgiann-media) beside FXServer as its own process. It stores screenshots, videos, audio, logs, statistics and database backups, and converts uploads. Heavy work (video conversion, queries, backups) never slows the game server down.
It starts and stops with the resource and restarts itself after a crash (after 1, 5, 15 and 60 seconds).
It shuts down by itself when FXServer exits.
It runs at a lower priority than FXServer.
FXServer's sandbox only lets it start with
add_unsafe_child_process_permission "tgiann-fivem-stats-script"inserver.cfg, see Installation.
Windows and Linux
media/bin holds both builds, the script picks the right one. Nothing to download or install, also on hosts where you cannot install programs.
tgiann-media.exe, ffmpeg.exe
Windows
tgiann-media, ffmpeg
Linux
On Linux the script makes both files executable on start. ffmpeg is a small LGPL build of FFmpeg with only the parts the service uses. Keep THIRD-PARTY-LICENSES.txt next to it.
Where files are stored
In tgiann-media/ inside the script folder (tgiann-fivem-stats-script/tgiann-media/). FXServer's sandbox only lets a resource use its own folder, so this place cannot be changed.
tgiann-media/
├── api-key made on the first start, see API key below
├── settings.json the settings you edit in the panel
├── stats.db statistics
├── media.db the list of files
├── logs.db server logs
├── files/ screenshots, videos, audio
├── backups/ database backups
├── bin/ a copy of the service the script runs
└── tls/ the HTTPS certificateTo keep statistics, logs and media when you move to a new machine, copy the whole tgiann-media folder. Database Backups only cover your game database.
Convars
All optional, set them before ensure tgiann-fivem-stats-script.
tgiann_media_host
0.0.0.0
The address it listens on. 127.0.0.1 behind a reverse proxy
tgiann_media_public_ip
found on start
The IP the auto certificate is made for
tgiann_media_tls_cert / tgiann_media_tls_key
Certificate files for custom
tgiann_media_ffmpeg
the build in media/bin
Use your own FFmpeg instead
tgiann_media_api_key
made on the first start
Use your own API key instead of the api-key file
The address in links (a domain, a reverse proxy) is not a convar. It is set in the panel: Settings > Media storage > Public address.
The service reads your framework tables and takes backups with oxmysql's mysql_connection_string. If server.cfg limits who can read it, add add_convar_permission tgiann-fivem-stats-script read mysql_connection_string.
File formats
Files a browser already plays are stored as they are: WebM (VP8, VP9, AV1 with Opus or Vorbis), MP3, OGG, WebP. MP4 (H.264) and M4A (AAC) are only rearranged so they start playing at once. Everything else is converted:
Video
WebM, VP9 and Opus
250 MB
Audio
Opus in OGG
50 MB
How long files are kept is set per type in Settings > Media storage (forever by default). Files marked Keep forever on the Media page are never removed.
API key
tgiann-media/api-key is the key the script uses to talk to the service, and the key tools outside FiveM send in the Authorization header. Keep it private. To change it, delete the file (or set tgiann_media_api_key) and restart the resource.
Last updated