mirror of
https://github.com/go-ffstatic/ffstatic
synced 2025-09-26 20:01:13 +08:00
add examples
This commit is contained in:
55
README.md
55
README.md
@@ -1,22 +1,14 @@
|
||||
# ffstatic
|
||||
|
||||
Embed ffmpeg and ffprobe static binaries into your go
|
||||
program and use them without preinstalled binaries.
|
||||
Embed ffmpeg and ffprobe static binaries into your go program and use them without preinstalled binaries.
|
||||
|
||||
This project is inspired
|
||||
by [ffmpeg-static](https://github.com/eugeneware/ffmpeg-static)
|
||||
.
|
||||
This project is inspired by [ffmpeg-static](https://github.com/eugeneware/ffmpeg-static).
|
||||
|
||||
## How it works
|
||||
|
||||
We use go embed to embed the ffmpeg/ffprobe binaries as
|
||||
bytes in go program. The real ffmpeg/ffprobe executable
|
||||
files would be created in system temp directory when you run
|
||||
the program.
|
||||
We use go embed to embed the ffmpeg/ffprobe binaries as bytes in go program. The real ffmpeg/ffprobe executable files would be created in system temp directory when you run the program.
|
||||
|
||||
With this package, you can use ffmpeg/ffprobe without
|
||||
preinstalling. It would be very helpful to run program on
|
||||
serverless platform (ie. lambda\Vercel).
|
||||
With this package, you can use ffmpeg/ffprobe without preinstalling. It would be very helpful to run program on serverless platform (ie. lambda/Vercel).
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -24,49 +16,82 @@ Choose the version matched with your environment.
|
||||
|
||||
- Darwin
|
||||
- amd64
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/darwin-amd64
|
||||
```
|
||||
|
||||
- arm64
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/darwin-arm64
|
||||
```
|
||||
|
||||
- Linux
|
||||
- amd64
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/linux-amd64
|
||||
```
|
||||
|
||||
- arm64
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/linux-arm64
|
||||
```
|
||||
|
||||
- arm
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/linux-arm
|
||||
```
|
||||
|
||||
- 386
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/linux-386
|
||||
```
|
||||
|
||||
- Windows
|
||||
- amd64
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/windows-amd64
|
||||
```
|
||||
|
||||
- 386
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/windows-386
|
||||
```
|
||||
|
||||
- FreeBSD
|
||||
- amd64
|
||||
|
||||
```sh
|
||||
go get -u github.com/go-ffstatic/freebsd-amd64
|
||||
```
|
||||
|
||||
## How to use
|
||||
## Basic Usage
|
||||
|
||||
## Cross compiling
|
||||
You can use `os/exec` to execute ffmpeg/ffprobe directly. I also recommend to use a ffmpeg wrapper, for example:
|
||||
|
||||
- [xfrr/goffmpeg](https://github.com/xfrr/goffmpeg)
|
||||
|
||||
- [floostack/transcoder](https://github.com/floostack/transcoder)
|
||||
|
||||
- [u2takey/ffmpeg-go](https://github.com/u2takey/ffmpeg-go)
|
||||
|
||||
- [AlexEidt/Vidio](https://github.com/AlexEidt/Vidio)
|
||||
|
||||
Check [examples/basic](./examples/basic) for more details.
|
||||
|
||||
## Cross-platform
|
||||
|
||||
If you want to run your program on multi platforms (dev on darwin, deploy on linux, etc.), you need using `go:build` constrain to cross compile.
|
||||
|
||||
Check [examples/cross-plaform](./examples/cross-plaform) for more details.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
MIT
|
||||
|
Submodule darwin-amd64 updated: 3be09c46cf...c00b1b8ed8
Submodule darwin-arm64 updated: f211cf8e6e...5e89ca54bd
8
examples/basic/go.mod
Normal file
8
examples/basic/go.mod
Normal file
@@ -0,0 +1,8 @@
|
||||
module github.com/go-ffstatic/ffstatic/examples/basic
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/floostack/transcoder v1.1.1 // indirect
|
||||
github.com/go-ffstatic/darwin-amd64 v0.0.0-20220419071301-3be09c46cfa9 // indirect
|
||||
)
|
4
examples/basic/go.sum
Normal file
4
examples/basic/go.sum
Normal file
@@ -0,0 +1,4 @@
|
||||
github.com/floostack/transcoder v1.1.1 h1:ApvdTZGt4r1N8dcT1PEl4jxX5OBHaOMY42kmCKNbYCE=
|
||||
github.com/floostack/transcoder v1.1.1/go.mod h1:lT+f8NEGaHP6AVeYLicas0EI0+TforD+DRuLziJg6bY=
|
||||
github.com/go-ffstatic/darwin-amd64 v0.0.0-20220419071301-3be09c46cfa9 h1:7m3vIAZFNmqJg1IpdvYnZKVi67pf6PjCrwZiP/mFSZQ=
|
||||
github.com/go-ffstatic/darwin-amd64 v0.0.0-20220419071301-3be09c46cfa9/go.mod h1:8dBlJ3xj3C3oGoLAE2u7c3Dl5Spk9cbiQs9IJWaHb54=
|
19
examples/basic/main.go
Normal file
19
examples/basic/main.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/floostack/transcoder/ffmpeg"
|
||||
ffstatic_darwin_amd64 "github.com/go-ffstatic/darwin-amd64"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ff := ffmpeg.New(&ffmpeg.Config{
|
||||
FfmpegBinPath: ffstatic_darwin_amd64.FFmpegPath(),
|
||||
FfprobeBinPath: ffstatic_darwin_amd64.FFprobePath(),
|
||||
})
|
||||
ch, err := ff.Input("./input.avi").Output("./output.mp4").Start(ffmpeg.Options{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for range ch {
|
||||
}
|
||||
}
|
10
examples/cross-plaform/darwin.go
Normal file
10
examples/cross-plaform/darwin.go
Normal file
@@ -0,0 +1,10 @@
|
||||
//go:build darwin
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
ff "github.com/go-ffstatic/darwin-amd64"
|
||||
)
|
||||
|
||||
var ffmpegPath = ff.FFmpegPath()
|
||||
var ffprobePath = ff.FFprobePath()
|
9
examples/cross-plaform/go.mod
Normal file
9
examples/cross-plaform/go.mod
Normal file
@@ -0,0 +1,9 @@
|
||||
module github.com/go-ffstatic/ffstatic/examples/cross-platform
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/floostack/transcoder v1.1.1
|
||||
github.com/go-ffstatic/darwin-amd64 v0.0.0-20220419102624-c00b1b8ed833
|
||||
github.com/go-ffstatic/linux-amd64 v0.0.0-20220419102626-3eb73541e19c
|
||||
)
|
6
examples/cross-plaform/go.sum
Normal file
6
examples/cross-plaform/go.sum
Normal file
@@ -0,0 +1,6 @@
|
||||
github.com/floostack/transcoder v1.1.1 h1:ApvdTZGt4r1N8dcT1PEl4jxX5OBHaOMY42kmCKNbYCE=
|
||||
github.com/floostack/transcoder v1.1.1/go.mod h1:lT+f8NEGaHP6AVeYLicas0EI0+TforD+DRuLziJg6bY=
|
||||
github.com/go-ffstatic/darwin-amd64 v0.0.0-20220419102624-c00b1b8ed833 h1:4aiRoGBPjvS26oU28sqa1H2Cv+6mLeLw14yTqnP1ijI=
|
||||
github.com/go-ffstatic/darwin-amd64 v0.0.0-20220419102624-c00b1b8ed833/go.mod h1:8dBlJ3xj3C3oGoLAE2u7c3Dl5Spk9cbiQs9IJWaHb54=
|
||||
github.com/go-ffstatic/linux-amd64 v0.0.0-20220419102626-3eb73541e19c h1:dOZdf/kSqBKoj8d/JeiCa5xuBx0g9w+Q3syEa9+QQkE=
|
||||
github.com/go-ffstatic/linux-amd64 v0.0.0-20220419102626-3eb73541e19c/go.mod h1:IBog11RNX7YKzt2nE5Qc0zuscWQYj5TfqY/QxTUOOpQ=
|
10
examples/cross-plaform/linux.go
Normal file
10
examples/cross-plaform/linux.go
Normal file
@@ -0,0 +1,10 @@
|
||||
//go:build linux
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
ff "github.com/go-ffstatic/linux-amd64"
|
||||
)
|
||||
|
||||
var ffmpegPath = ff.FFmpegPath()
|
||||
var ffprobePath = ff.FFprobePath()
|
18
examples/cross-plaform/main.go
Normal file
18
examples/cross-plaform/main.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/floostack/transcoder/ffmpeg"
|
||||
)
|
||||
|
||||
func main() {
|
||||
ff := ffmpeg.New(&ffmpeg.Config{
|
||||
FfmpegBinPath: ffmpegPath,
|
||||
FfprobeBinPath: ffprobePath,
|
||||
})
|
||||
ch, err := ff.Input("./input.avi").Output("./output.mp4").Start(ffmpeg.Options{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for range ch {
|
||||
}
|
||||
}
|
Submodule freebsd-amd64 updated: 2f1e4e61d5...d69f9890f2
Submodule linux-386 updated: 3828709dc1...c4be39241f
Submodule linux-amd64 updated: f5dbdc64e4...3eb73541e1
Submodule linux-arm updated: f898b4e573...44f0824251
Submodule linux-arm64 updated: 7e1df52b60...ad06d6bc0d
@@ -1,6 +1,4 @@
|
||||
//generated by github.com/go-ffstatic/ffstatic
|
||||
//go:build {{.system}} && {{.arch}}
|
||||
// +build {{.system}},{{.arch}}
|
||||
// generated by github.com/go-ffstatic/ffstatic
|
||||
|
||||
package ffstatic_{{.system}}_{{.arch}}
|
||||
|
||||
|
Submodule windows-386 updated: e91058e0a3...836071e44d
Submodule windows-amd64 updated: 4ec6fbdd0c...7476d31d38
Reference in New Issue
Block a user