This project will automatically encoded fightcade replays and upload them to archive.org: Gino Lisignoli - Archive.org or youtube: fightcade archive
A web site the view the archive.org replays is here: https://fightcadevids.com
fcreplay is primarly a python application used to automate the generation of fightcade replays as video files.
The goal of this is to make fightcade replays accessible to anyone to watch without using an emulator.
fcreplay has several features to automate the encoding process and add aditional data to the generated videos
A desctiption is generated that contains:
- The fightcade replay id
- The fightcade player ids
- The fightcade player locations
- The game being played
- The date the game was played
- (Optional) A appended description
Fcreplay uses sqlalchemy and has been tested with postgres and is used store any replay metadata
Fcreplay is designed to run on google cloud
To trigger recording the file started.inf
is checked. If the file exists then pyautogui is used to start recording the avi file(s)
The i3 window manager is used to ensure that the fcadefbneo window is always in the same place.
This is all done in a headless X11 session
- Better exception handling.
- Thumbnails are generated but not used
To run this, you need:
- A VM or physical machine.
- With at least 4 Cores (Fast ones would be ideal)
- With at least 4GB Ram
- With at least 250GB of storage
- This is the amount of temporary storage required to encode a replay of up to 3 hours long. Replay recording requires ~20MB/sec
- Running Fedora 32
- Some familiarity with linux will help
To upload files to youtube.com you need to setup a youtube api endpoint. See here: https://github.com/tokland/youtube-upload
To upload files to archive.org, set the configuration key upload_to_ia
to true
and configure the ia section in the configuration file. You will also need to have your .ia
secrets file in your users home directory. This can be generated by running ia configure
from the command line once you have setup the python virtual environment.
The defaults should work if you follow the guide below.
If you are using the ansible playbook, you will also want to have ready the following files:
- Configuration file:
config.json
- Appened description:
description_append.txt
- Google cloud storage credentials:
.stroage_creds.json
- Google api client secrets:
.client_secrets.json
- Youtube upload credentials:
.youtube-upload-credentials.json
- Archive.org secrets:
.ia
To deploy to google cloud you need to:
- Create a project
- Create a fedora32 image
- This was done by following: https://linuxhint.com/install-fedora-google-compute-engine
- Install google-fluentd
- Create the base instance from the fedora32 image called fcreplay-image
- Create a service account "fcrecorder-compute-admin"
- Give it the folowing roles:
- Cloud Functions Invoker
- Compute Admin
- Logs Configuration Writer
- Logs Writer
- Monitoring Metric Writer
- Service Account User
- Make add this in your config.json file
- Give it the folowing roles:
- Deploy the cloud functions
I've include a basic ansible playbook for the installation, you will need to have ssh access to the fcreplay-image
and a deployment user with root access.
- Use the ansible script to setup the base instance.
- Create a deployment user with with sudo access:
adduser deployment
- Set a password
passwd deployment
- Add the user to the wheel group:
groupmems -a deployment -g wheel
- Copy your ssh key with
ssh-copy-id deployment@<host>
- Disable password login in the
/etc/ssh/sshd_config
and restart sshd:systemctl restart sshd
- Launch the ansible script:
- Development:
ansible-playbook -i <host>, -u <deployment_user> -K --diff --extra-vars '{"FC2_PATH": "/path/to/local/FC2", "gitbranch": "master" }' playbook.yml
- Google Cloud:
ansible-playbook -i <host>, -u <deployment_user> -K --diff --extra-vars '{"gcloud": True, "FC2_PATH": "/path/to/local/FC2", "gitbranch": "master" }' playbook.yml
- Google Cloud auto destroy:
ansible-playbook -i <host>, -u <deployment_user> -K --diff --extra-vars '{"destroy": True, "gcloud": True, "FC2_PATH": "/path/to/local/FC2", "gitbranch": "master" }' playbook.yml
- Development:
- After running the ansible script, you will need to start a xorg session and run
wine /home/fcrecorder/fcreplay/Fightcade/emulator/fbneo/fcadefbneo.exe
once to initialise wine - Then run in a xorg session, run winetricks and install:
- allcodecs
- avifil32
- cinepack
- xvid
- Create a deployment user with with sudo access:
If you want to watch recording happening, you need to:
- Login and switch to the fcrecorder user
- Create a x11vnc password as the fcrecorder user
x11vnc -storepasswd
- Add a firewalld rule to allow connections
firewall-cmd '--add-port 5900/tcp
When recording is happening, you can then run x11vnc --rfbauth ~/.vnc/passwd -noxfixes -noxdamage -noxrecord
as the fcrecord user. This will start a vnc server allowing you to connect to your instance on port 5900
When deploying with the ansible playbook, and the ansible variable "gcloud": True
, the fcrecord service is automatically set to start when the hostname is fcreplay-image-1
This will cause fcreplayloop --gcloud
to be automatically run when the instance is started. See loop.py
for more info
The typical useage of fcreplay is to run this in google cloud, where the service
Before running fcreplay, you need to activate the python environment
cd ~/fcreplay
source ./venv/bin/activate
This will download a replay, and place it in the database
fcreplayget <fightcade profile> <replay url>
Within a Xorg session:
fcreplayloop
You can also run fcreplayloop --debug
to only run for a single iteration. Useful for testing.
To run fcreplay automatically on startup you need to enable the service, and uncommet the i3 line:
systemctl enable fcrecord
sed -i 's/^# exec "xterm/exec "xterm/' .config/i3/config
Once you have setup the base image, you need to make a image called: fcrecord:
gcloud compute images create fcreplay-image \
--source-disk fcrecorder\
--source-disk-zone us-central1-a \
--family fedora32 \
--storage-location us-central1
Once started, the instance will look for a replay on startup and begin encoding.
If you want to see the logs, the following query should work:
(logName="projects/fcrecorder/logs/fcreplay" AND labels."compute.googleapis.com/resource_name" = "fcreplay-image-1") OR
(resource.type="cloud_function" AND severity=INFO AND labels.execution_id:*)
To create a scheduled job, run:
gcloud scheduler jobs create http 'check-for-replay' --schedule='*/2 * * * *' \
--uri="https://us-central1-fcrecorder-286007.cloudfunctions.net/check_for_replay" \
--oidc-service-account-email="fcrecorder-compute-account@fcrecorder-286007.iam.gserviceaccount.com" \
--oidc-token-audience="https://us-central1-fcrecorder-286007.cloudfunctions.net/check_for_replay"