Scripts Documentation¶
This section documents shell scripts currently used in batemanRecords.
bateman.sh¶
app/bateman.sh¶
1#!/bin/bash
2cd "$(dirname "$0")/.."
3poetry run python -m app.application "$@"
Runs the CLI entrypoint with Poetry.
./app/bateman.sh "<YOUTUBE_URL>"
Video Generation Scripts¶
combineAudioVideo.sh¶
app/scripts/combineAudioVideo.sh¶
1#!/bin/bash
2
3audioPath=$1
4videoPath=$2
5delay=$3 # delay in seconds
6
7# Check if audioPath is not empty
8if [[ -z "$audioPath" ]]; then
9 read -p "path to audio file: " audioPath
10fi
11# Check if videoPath is not empty
12if [[ -z "$videoPath" ]]; then
13 read -p "path to video file: " videoPath
14fi
15
16currentTime=$(date +"%H-%M-%S")
17outputFileName="combined_$currentTime.mp4"
18outputFilePath="./outputs/combined/$outputFileName"
19# create directory if it doesn't exist already
20[ -d "./outputs/combined" ] || mkdir -p "./outputs/combined"
21
22callFFMPEG() {
23 ffmpeg -i $videoPath -ss $delay -i "$audioPath" -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 -shortest $outputFilePath
24}
25
26callFFMPEG
27
28echo "$outputFilePath"
Combines generated video with downloaded audio and applies the chosen audio offset.
./app/scripts/combineAudioVideo.sh input_audio.mp3 input_video.mp4 0
generateVideoYoutube.sh¶
app/scripts/generateVideoYoutube.sh¶
1#!/bin/bash
2
3# Use the first argument as the path to background image
4bgImagePath=$1
5
6# Check if bgImagePath is not empty
7if [[ -z "$bgImagePath" ]]; then
8 read -p "path to background image: " bgImagePath
9fi
10
11# To get the current time in the format Hour:Minute:Second
12currentTime=$(date +"%H-%M-%S")
13
14batemanVideoPath="./assets/bateman_original_double.mp4"
15outputFileName="youtube_$currentTime.mp4"
16outputFilePath="./outputs/youtube/$outputFileName"
17# create directory if it doesn't exist already
18[ -d "./outputs/youtube" ] || mkdir -p "./outputs/youtube"
19
20callFFMPEG() {
21 ffmpeg -i "$bgImagePath" -i "$batemanVideoPath" -filter_complex \
22 "[0:v]scale=-1:1080[bg];[1:v]colorkey=0x00C04C:0.2:0.1[keyed]; \
23 [bg][keyed]overlay=(W-w)/2:(H-h)/2" \
24 $outputFilePath
25}
26
27callFFMPEG
28
29# Print the path to the generated video file
30echo "$outputFilePath"
Generates the Bateman background-composited video from a thumbnail image.
./app/scripts/generateVideoYoutube.sh [bgImagePath]