A Python utility for uploading Shotcut projects to a server for rendering/exporting.
Shotcut is an open-source, cross-platform video editor built upon the MLT framework. This was originally written so I could reuse a Linux Mint desktop as a rendering/export server for Shotcut, along with getting some further experience with Python.
This performs the following tasks in order:
- Parse required arguments.
- Read configuration from the config.yml file.
- Issue a ping command to the server to check if it is up (and exit if this fails).
- Parse the MLT file into which Shotcut saves projects, looking for any tag defined as
<property name="resource">
. - Copy each file mentioned in the above tags to the local directory and strip out the path from the tag. This effectively points the Shotcut project at the local files instead of using absolute paths
- Rewrite the MTL file's XML tree into a new file to preserve the original.
- Upload all files to the server.
- Delete the temporary files
- There may be issues on different operating systems. This is currently tested on Ubuntu under WSL, but the original development work was done under Git Bash on Windows.
- This will not open Shotcut on the remote server, and using the MLT framework directly has not been tested.
- There is currently no way to check when Shotcut has finished exporting.
- A server with Shotcut installed. SSH must be enabled on this and set to use SSH keys.
- Python 3.8.10 or later on your local machine
Install the required packages (paramiko and pyyaml) by running pip install -r requirements.txt
.
If SSH is not set up on your server (e.g. you are repurposing an old desktop) or does not use SSH keys, set up SSH as follows:
- Set your server to have a static IP address. Doing so is beyond the scope of this guide.
- Enable SSH on the server by running
systemctl enable sshd
. Optionally, set it to use a port other than 22. - Create an SSH key by running
ssh-keygen
on your local computer.- Take note of the path to the file; this utility expects the filename to be "id_rsa".
- Fill out the passphrase. Take note of this for later.
- Copy this to your server by running
ssh-copy-id user@server
, e.g.ssh-copy-id admin@1.2.3.4
. When prompted for a password, use the password associated with the remote server. Do not use the passphrase for the SSH key.
Copy the config.example.yml file to config.yml and update as follows:
- Replace the username field with the username you will use to access the server
- Replace the host with the IP address or hostname of the server.
- If your server uses a different port to 22 (the standard SSH/SFTP port), replace the port entry with the expected value.
- Replace the path in the key_path variable with the actual path to the folder that contains the
id_rsa
file. In most cases, this will be$HOME/.ssh
. - Replace the key_pass variable with the passphrase defined above.
Run the following command: python3 uploader.py path/to/mlt_file path/to/remote_dir
, e.g. python3 uploader.py examples/PyShotcutUploader.mlt Videos/UploadedFailer
Both parameters are required.
- The
mlt_file
is the format in which Shotcut saves projects. - The
remote_dir
is the remote directory to which to upload them, relative to the remote user's home directory (e.g. Videos/Test instead of /home/admin/Videos/Test)
- Check that you haven't missed the config.yml file and that all paths are correct in the Shotcut project.
- Check that the SSH host, port, SSH key and passphrase match that of the server
MIT (see the LICENCE file).
- MODEM_3.aiff (CC0)
- wah wah sad trombone.wav (CC0)