Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
connerdouglass committed Mar 7, 2024
1 parent 209b1f1 commit 2a74f36
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 14 deletions.
34 changes: 34 additions & 0 deletions cmd/filtergen/filters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,40 @@ filters:
key: exact
type: [bool]

- name: trim
func: Trim
outputs: 1
options:
- name: StartSeconds
key: start
type: [expr, string]
- name: EndSeconds
key: end
type: [expr, string]
- name: StartFrame
key: start_frame
type: [int]
- name: EndFrame
key: end_frame
type: [int]

- name: rotate
func: Rotate
outputs: 1
options:
- name: Angle
key: a
type: [expr]
- name: FillColor
key: c
type: [string]
- name: OutputWidth
key: out_w
type: [expr, int]
- name: OutputHeight
key: out_h
type: [expr, int]

- name: geq
func: GenericEquation
outputs: 1
Expand Down
30 changes: 16 additions & 14 deletions examples/colorchart/main.go → examples/overlay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,35 @@ import (
"time"

"github.com/spiretechnology/spireav"
"github.com/spiretechnology/spireav/filter/expr"
"github.com/spiretechnology/spireav/filter/filters"
"github.com/spiretechnology/spireav/output"
)

func main() {
// Create a new graph
g := spireav.New()
// inputNode := g.Input("reference-media/BigBuckBunny.mp4")
outputNode := g.Output("reference-outputs/out-colorchart.mp4", output.WithFormatMP4())

textOverlay := g.Filter(filters.DrawText().Text("SpireAV Test"))
videoSrc := g.Filter(filters.SMPTEHDBars().Duration("10").FrameRate(expr.Int(30)))
spireav.Pipeline(videoSrc, textOverlay, outputNode)
background := g.Filter(filters.NullSource().Duration("10").Size(1280, 720))

// Sin wave from 300 to 1000 Hz, period of 2 seconds
// freq := expr.Add(expr.Int(300), expr.Mul(expr.Int(700), expr.Sin0to1("t")))
freq := expr.Int(440)
fmt.Println(freq.String())
fmt.Println()
foreground := g.Input("reference-media/BigBuckBunny.mp4")
scaleForeground := g.Filter(filters.Scale().WidthInt(200).HeightInt(200))
foreground.Pipe(scaleForeground, 0)

audioSrc := g.Filter(filters.SineSource().Frequency(freq).Duration("10"))
audioSrc.Pipe(outputNode, 1)
rotateForeground := g.Filter(filters.Rotate().Angle("t*PI/4"))
scaleForeground.Pipe(rotateForeground, 0)

overlayFilter := g.Filter(filters.Overlay().PosX("0").PosY("0"))
background.Pipe(overlayFilter, 0)
rotateForeground.Pipe(overlayFilter, 1)

outputFile := g.Output("reference-outputs/out-overlay.mp4", output.WithFormatMP4())

overlayFilter.Pipe(outputFile, 0)
foreground.Stream(1).Pipe(outputFile, 1)

// Create a progress handler function
progressFunc := func(progress spireav.Progress) {
fmt.Printf("P: %+v\n", progress)
// fmt.Printf("P: %+v\n", progress)
fmt.Printf("E: %+v\n", progress.Estimate)
}

Expand Down
79 changes: 79 additions & 0 deletions filter/filters/rotate.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions filter/filters/trim.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a74f36

Please sign in to comment.