Skip to content

Commit

Permalink
Merge branch 'main' into verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
Davideo37 committed Apr 27, 2022
2 parents 69d1760 + d13833c commit 78d5d92
Show file tree
Hide file tree
Showing 21 changed files with 1,332 additions and 1,152 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
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 }}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
*.mp4
.goreleaser.yaml
dist/
32 changes: 32 additions & 0 deletions .goreleaser.yaml
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:"
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,40 @@ Inputs Template Documentation: [Link](slideshow.md)<br>
Design Document: [Link](https://docs.google.com/document/d/1vjogjaWZ0ww7rJtKz3J4iuVbbFrZF3KASdHBW-zPYfE/edit#)

# How-To Documentation

1. Download FFmpeg https://www.ffmpeg.org by selecting the appropriate .zip for your OS. Make sure the version number is greater than 4.3.0 to make full use of our code (Here's a basic tutorial for [Windows](https://www.wikihow.com/Install-FFmpeg-on-Windows), [Mac using Homebrew](https://sites.duke.edu/ddmc/2013/12/30/install-ffmpeg-on-a-mac/), and [Linux using a PPA with ffmpeg v4.4.1](https://launchpad.net/~savoury1/+archive/ubuntu/ffmpeg4))
When installing with Homebrew (`brew install ffmpeg –ANY-OPTIONS-YOU-WANT`), ignore special options. Run `brew install ffmpeg` instead.
3. Download and extract executable for your system from repo's releases
4. Put any images (.png, .jpg, etc) and audios (.mp3, .wav, etc) into a folder, and also include a .slideshow xml file with proper parameters for the video ([.slideshow documentation linked here](https://github.com/gordon-cs/appbuilder-storybuilder/blob/main/slideshow.md))
5. Run code in a CLI set to directory of executable with "./executable_name" or just "executable_name" for Windows
6. There are also several flags you can include at runtime to alter the output or inputs:

-h : Help, display list of possible flags and their uses

-t : Template, used to input a specific template file to use, otherwise the program searches executable's current directory for any .slideshow files and uses the first it finds

-o : Output location, used to specify where to store the finished video, will use executable's current directory by default

-l : Lower quality, used to generate a lower quality video for smaller file size for easier distribution (default videos will be 1280x720)

-td : Temporary Directory, used to specify a location to store the temporary files used in video production (default is in your OS' temp directory/storybuilder-*)

-v : Verbosity, used to modify how much output is reported on the commandline for debugging purposes (less verbose by default)

-s : Save files, used to specify if user wants to preserve the temporary files used in the video production (videos are deleted by default)

-ov : Overlay video, used to specify the location of a test video to create an overlay video with the generated video
When installing with Homebrew (`brew install ffmpeg –ANY-OPTIONS-YOU-WANT`), ignore special options. Run `brew install ffmpeg` instead.
2. Download and extract executable for your system from repo's releases
3. Put any images (.png, .jpg, etc) and audios (.mp3, .wav, etc) into a folder, and also include a .slideshow xml file with proper parameters for the video ([.slideshow documentation linked here](https://github.com/gordon-cs/appbuilder-storybuilder/blob/main/slideshow.md))
4. Run code in a CLI set to directory of executable with "./executable_name" or just "executable_name" for Windows
5. There are also several flags you can include at runtime to alter the output or inputs:


-h : Help, display list of possible flags and their uses

-t : Template, used to input a specific template file to use, otherwise the program searches executable's current directory for any .slideshow files and uses the first it finds

-o : Output location, used to specify where to store the finished video, will use executable's current directory by default

-l : Lower quality, used to generate a lower quality video for smaller file size for easier distribution (default videos will be 1280x720)

-td : Temporary Directory, used to specify a location to store the temporary files used in video production (default is in your OS' temp directory/storybuilder-\*)

-v : Verbosity, used to modify how much output is reported on the commandline for debugging purposes (less verbose by default)

-s : Save files, used to specify if user wants to preserve the temporary files used in the video production (videos are deleted by default)

-f : Fadetype, include to use the non-xfade default transitions for video

-ov : Overlay video, used to specify the location of a test video to create an overlay video with the generated video

# Testing Documentation

Our source code can be tested using our provided unit tests in main_test.go, to which we are adding more tests as we progress. This is run as follows:
1. Ensure GoLang is installed properly, from their website [link]( https://golang.org/dl/ )
2. Navigate to folder with source code with a CLI and run "go test" to execute all the unit tests provided and ensure all tests pass.
Our source code contains unit tests per packages, to which we are adding more tests as we progress. This is run as follows:

If more thorough testing is desired, or if a unit test fails for some undiscoverable reason, one can manually test our code by downloading and running our code
with our provided [Test Folder](https://github.com/gordon-cs/appbuilder-storybuilder/tree/main/Test%20Input) which contains a simple template with a few images that can be used to verify if the code is functioning properly.
1. Ensure GoLang is installed properly, from their website [link](https://golang.org/dl/)
2. Navigate to folder with source code with a CLI and run "go test ./..." to execute all the unit tests for all packages and ensure all tests pass.
3. Run "go test test_filename.go" to run specific test files.

# Release Documentation

Expand All @@ -58,9 +61,8 @@ In order to generate a release version for our code after making adjustments you
5. Create a folder in your `homedirectory~/.config/` directory labeled `goreleaser` if it doesn't already exist
6. Copy your token into a file called `github_token` and place it into the `goreleaser` folder you created.
7. With your CLI set to the folder with your source code and the `.goreleaser.yaml` file, create a tag for your release with `git tag -a TAG_ID -m TAG_MESSAGE`(e.g. `git tag -a v0.1.0 -m "Release Version 0.1.0"`)
8. Push your tag using `git push origin TAG_ID` (e.g. `git push origin v0.1.0`)
9. Now in that same directory run `goreleaser release` and let GoReleaser do the building and publishing for you!
8. Push your tag using `git push origin TAG_ID` (e.g. `git push origin v0.1.0`), and GitHub Actions will take care of the building!

(Optional) 10. If you wish to compile without releasing to GitHub you can use `goreleaser build` or `goreleaser release --skip-publish` in your source code directory to prevent publishing to GitHub
(Optional) 9. If you wish to compile without releasing to GitHub you can use `goreleaser build` or `goreleaser release --skip-publish` in your source code directory to prevent publishing to GitHub

If any of these steps cause issues you can reference the [GoReleaser documentation](https://goreleaser.com/)
Binary file modified TestInput/Jn01.1-18-title.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion go.mod
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
94 changes: 94 additions & 0 deletions main.go
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
}
}
2 changes: 0 additions & 2 deletions src/.gitignore

This file was deleted.

48 changes: 0 additions & 48 deletions src/cmd.go

This file was deleted.

Loading

0 comments on commit 78d5d92

Please sign in to comment.