-
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
1 parent
d129b8a
commit 917a399
Showing
284 changed files
with
2,405 additions
and
963 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
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
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
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,62 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"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/BigBuckBunny-timecode.mp4", | ||
output.WithFormatMP4(), | ||
) | ||
|
||
// Overlay timecode on the video | ||
timecode := g.Filter( | ||
filters.Drawtext(). | ||
Timecode("00:00:00:00"). | ||
TimecodeRate(expr.RateFilm). | ||
Fontcolor(expr.ColorWhite). | ||
Box(true). | ||
Boxcolor(expr.ColorBlack.WithOpacity(0.5)). | ||
FontsizeExpr(expr.Div(expr.Var("h"), expr.Int(10))). | ||
XExpr(expr.Div(expr.Sub(expr.Var("w"), expr.Var("tw")), expr.Int(2))). | ||
YExpr(expr.Sub(expr.Var("h"), expr.Var("th"), expr.Int(20))), | ||
) | ||
|
||
// Pass the video into the pipeline | ||
inputNode.Video(0).Pipe(timecode, 0) | ||
|
||
// Pass the pipeline output to the output file | ||
timecode.Pipe(outputNode, 0) | ||
|
||
// Pass the audio directly to the output file | ||
inputNode.Audio(0).Pipe(outputNode, 1) | ||
|
||
// Create a progress handler function | ||
progressFunc := func(progress spireav.Progress) { | ||
fmt.Printf("%+v\n", progress) | ||
} | ||
|
||
// Create a context for the transcoding job | ||
ctx := context.Background() | ||
ctx, cancel := context.WithTimeout(ctx, 60*time.Second) | ||
defer cancel() | ||
|
||
// Create the process | ||
runner := spireav.NewRunner(g, spireav.WithProgressCallback(progressFunc)) | ||
|
||
// Run the transcoding job | ||
if err := runner.Run(ctx); err != nil { | ||
fmt.Println(err.Error()) | ||
} | ||
} |
Oops, something went wrong.