This script automates the adapting Apex Legends game highlights from 1920x1080 landscape to portrait for easy sharing on YouTube Shorts, TikTok, Instagram, etc.
This program loops through all the files in a folder, masks out the player's health bar, moves it to the top of the frame, crops the footage to a 9 by 16 aspect ratio, adds an optional logo, and exports it to an H.264 format.
This program runs on Python 3 and only requires one non-included library: moviepy. To install moviepy, just run pip install moviepy
in your terminal or pip install -r requirements.txt
.
Here are some examples of how the input and output formats of the program. The footage used below is a 1920x1080 60p quicktime file captured using OBS. I recommend using the replay capture, as it can automatically create clips that are specific lengths (30, 60, 90 seconds).
You can import this program into another script or run it directly from the command line. For example:
python3 ./apex_shorts.py -s './ingest/test.mp4' -d './exports'
If you wanted to trim the origional file to start at 3 seconds and end at 10 seconds, you type:
python3 ./apex_shorts.py -s './ingest/test.mp4' -d './exports' -i 3 -o 10
Here are all of the flags that are available for use:
-s
or --source
The source directory (where all of our game recordings are)
-d
or --destination
The export directory (where you want to export the edited files)
-i
or --inpoint
When you want the video to start (in seconds)
-o
or --outpoint
When you want the video to end (in seconds)
-r
or --overwrite
Allows you to overwrite files in case you encounter any exporting errors
-w
or --watermark
Allows you to specify a specific filepath for your watermark. You'll need to include the filepath after this flag. For example: -w 'path/to/file.png'
-b
or --hidehealthbar
Allows you to disable the healthbar overlay
--stretch
Sets the healthbar overlay to work with 16x10 aspect ratio recordings.
For best results, use a 500 x 500 pixel transparent PNG for your watermark.
This program has not been tested using footage that is not 1920x1080. If you use alternative aspect ratios, your mileage may vary. I've added support for 16x10 aspect ratios in the last update, but it assumes it's still 1920x1080 with black bars on the side.