forked from gordon-cs/appbuilder-storybuilder
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
1,332 additions
and
1,152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: goreleaser | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
workflow_dispatch: | ||
inputs: | ||
logLevel: | ||
description: "Log Level" | ||
required: true | ||
default: "warning" | ||
tags: | ||
descriptions: "Tags" | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
goreleaser: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Fetch all tags | ||
run: git fetch --force --tags | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
|
||
- name: Run GoReleaser | ||
uses: goreleaser/goreleaser-action@v2 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.DS_Store | ||
*.mp4 | ||
.goreleaser.yaml | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This is an example .goreleaser.yml file with some sensible defaults. | ||
# Make sure to check the documentation at https://goreleaser.com | ||
before: | ||
hooks: | ||
# You may remove this if you don't use go modules. | ||
- go mod tidy | ||
# you may remove this if you don't need go generate | ||
- go generate ./... | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- darwin | ||
archives: | ||
- replacements: | ||
darwin: Darwin | ||
linux: Linux | ||
windows: Windows | ||
386: i386 | ||
amd64: x86_64 | ||
checksum: | ||
name_template: "checksums.txt" | ||
snapshot: | ||
name_template: "{{ incpatch .Version }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- "^docs:" | ||
- "^test:" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module github.com/gordon-cs/SIL-Video/Compiler | ||
module github.com/sillsdev/appbuilder-storybuilder | ||
|
||
go 1.17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package main | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"io/fs" | ||
"path/filepath" | ||
"regexp" | ||
"time" | ||
|
||
"github.com/sillsdev/appbuilder-storybuilder/src/helper" | ||
"github.com/sillsdev/appbuilder-storybuilder/src/options" | ||
OS "github.com/sillsdev/appbuilder-storybuilder/src/os" | ||
"github.com/sillsdev/appbuilder-storybuilder/src/slideshow" | ||
) | ||
|
||
var filePath string | ||
|
||
// Main function | ||
func main() { | ||
// Ask the user for options | ||
optionFlags := options.ParseFlags() | ||
|
||
// Create a temporary folder to store temporary files | ||
tempDirectory, err := OS.CreateDirectory(optionFlags.TemporaryDirectory) | ||
helper.Check(err) | ||
|
||
// Create directory if output directory does not exist | ||
if optionFlags.OutputDirectory != "" { | ||
_, err := OS.CreateDirectory(optionFlags.OutputDirectory) | ||
helper.Check(err) | ||
} | ||
|
||
// Search for a template in local folder if no template is provided | ||
if optionFlags.SlideshowDirectory == "" { | ||
fmt.Println("No template provided, searching local folder...") | ||
|
||
err := filepath.WalkDir(".", findTemplate(optionFlags.SlideshowDirectory)) | ||
|
||
if err.Error() == "FOUND TEMPLATE" { | ||
optionFlags.SetSlideshowDirectory(filePath) | ||
} | ||
} | ||
|
||
start := time.Now() | ||
|
||
// Parse in the various pieces from the template | ||
slideshow := slideshow.NewSlideshow(optionFlags.SlideshowDirectory) | ||
|
||
fmt.Println("Scaling images...") | ||
slideshow.ScaleImages(optionFlags.LowQuality) | ||
|
||
fmt.Println("Creating video...") | ||
slideshow.CreateVideo(optionFlags.UseOldFade, tempDirectory, optionFlags.OutputDirectory) | ||
|
||
fmt.Println("Video production completed!") | ||
duration := time.Since(start) | ||
fmt.Sprintln(fmt.Sprintf("Time Taken: %f seconds", duration.Seconds())) | ||
|
||
if optionFlags.OverlayVideoDirectory != "" { | ||
fmt.Println("Creating overlay video...") | ||
|
||
finalVideoDirectory := tempDirectory + "/final.mp4" | ||
|
||
slideshow.CreateOverlaidVideo(finalVideoDirectory, optionFlags.OverlayVideoDirectory, optionFlags.OutputDirectory) | ||
fmt.Println("Finished creating overlay video") | ||
} | ||
|
||
// If user did not specify the -s flag at runtime, delete all the temporary videos | ||
if !(optionFlags.SaveTemps) { | ||
err := OS.DeleteTemporaryDirectory(tempDirectory) | ||
helper.Check(err) | ||
} | ||
|
||
} | ||
|
||
func findTemplate(slideshowDirectory string) fs.WalkDirFunc { | ||
return func(path string, d fs.DirEntry, e error) error { | ||
slideRegEx := regexp.MustCompile(`.+(.slideshow)$`) // Regular expression to find the .slideshow file | ||
if e != nil { | ||
return e | ||
} | ||
if slideRegEx.MatchString(d.Name()) { | ||
if slideshowDirectory == "" { | ||
fmt.Println("Found template: " + path + "\nUsing found template...") | ||
|
||
filePath = path | ||
return errors.New("FOUND TEMPLATE") | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.