-
-
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.
Merge pull request #12 from dpolakovics/11-switch-to-ffstatic
feat: add ffmpeg binaries
- Loading branch information
Showing
12 changed files
with
203 additions
and
0 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,2 @@ | ||
ffmpeg filter=lfs diff=lfs merge=lfs -text | ||
ffprobe filter=lfs diff=lfs merge=lfs -text |
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,73 @@ | ||
//go:build darwin | ||
// +build darwin | ||
|
||
package ffmpeg | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"os" | ||
"runtime" | ||
) | ||
|
||
//go:embed darwin_amd64/ffmpeg | ||
var ffmpegAmd64 []byte | ||
//go:embed darwin_amd64/ffprobe | ||
var ffprobeAmd64 []byte | ||
|
||
//go:embed darwin_arm64/ffmpeg | ||
var ffmpegArm64 []byte | ||
//go:embed darwin_arm64/ffprobe | ||
var ffprobeArm64 []byte | ||
|
||
func writeTempExec(pattern string, binary []byte) (string, error) { | ||
f, err := os.CreateTemp("", pattern) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create temp file: %v", err) | ||
} | ||
defer f.Close() | ||
_, err = f.Write(binary) | ||
if err != nil { | ||
return "", fmt.Errorf("fail to write executable: %v", err) | ||
} | ||
if err := f.Chmod(os.ModePerm); err != nil { | ||
return "", fmt.Errorf("fail to chmod: %v", err) | ||
} | ||
return f.Name(), nil | ||
} | ||
|
||
var ( | ||
ffmpegPath string | ||
ffprobePath string | ||
) | ||
|
||
func FFmpegPath() string { return ffmpegPath } | ||
|
||
func FFprobePath() string { return ffprobePath } | ||
|
||
func init() { | ||
var err error | ||
|
||
switch runtime.GOARCH { | ||
case "amd64": | ||
ffmpegPath, err = writeTempExec("ffmpeg_linux_amd64", ffmpegAmd64) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to write ffmpeg_linux_amd64: %v", err)) | ||
} | ||
ffprobePath, err = writeTempExec("ffprobe_linux_amd64", ffprobeAmd64) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to write ffprobe_linux_amd64: %v", err)) | ||
} | ||
case "arm64": | ||
ffmpegPath, err = writeTempExec("ffmpeg_linux_amd64", ffmpegArm64) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to write ffmpeg_linux_amd64: %v", err)) | ||
} | ||
ffprobePath, err = writeTempExec("ffprobe_linux_amd64", ffprobeArm64) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to write ffprobe_linux_amd64: %v", err)) | ||
} | ||
default: | ||
panic(fmt.Errorf("Running on an unknown architecture: %s\n", runtime.GOARCH)) | ||
} | ||
} |
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
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,52 @@ | ||
//go:build linux && amd64 | ||
|
||
package ffmpeg | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
//go:embed linux_amd64/ffmpeg | ||
var ffmpeg []byte | ||
|
||
//go:embed linux_amd64/ffprobe | ||
var ffprobe []byte | ||
|
||
func writeTempExec(pattern string, binary []byte) (string, error) { | ||
f, err := os.CreateTemp("", pattern) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create temp file: %v", err) | ||
} | ||
defer f.Close() | ||
_, err = f.Write(binary) | ||
if err != nil { | ||
return "", fmt.Errorf("fail to write executable: %v", err) | ||
} | ||
if err := f.Chmod(os.ModePerm); err != nil { | ||
return "", fmt.Errorf("fail to chmod: %v", err) | ||
} | ||
return f.Name(), nil | ||
} | ||
|
||
var ( | ||
ffmpegPath string | ||
ffprobePath string | ||
) | ||
|
||
func FFmpegPath() string { return ffmpegPath } | ||
|
||
func FFprobePath() string { return ffprobePath } | ||
|
||
func init() { | ||
var err error | ||
ffmpegPath, err = writeTempExec("ffmpeg_linux_amd64", ffmpeg) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to write ffmpeg_linux_amd64: %v", err)) | ||
} | ||
ffprobePath, err = writeTempExec("ffprobe_linux_amd64", ffprobe) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to write ffprobe_linux_amd64: %v", err)) | ||
} | ||
} |
Git LFS file not shown
Git LFS file not shown
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,52 @@ | ||
//go:build windows && amd64 | ||
|
||
package ffmpeg | ||
|
||
import ( | ||
_ "embed" | ||
"fmt" | ||
"os" | ||
) | ||
|
||
//go:embed windows_amd64/ffmpeg | ||
var ffmpeg []byte | ||
|
||
//go:embed windows_amd64/ffprobe | ||
var ffprobe []byte | ||
|
||
func writeTempExec(pattern string, binary []byte) (string, error) { | ||
f, err := os.CreateTemp("", pattern) | ||
if err != nil { | ||
return "", fmt.Errorf("failed to create temp file: %v", err) | ||
} | ||
defer f.Close() | ||
_, err = f.Write(binary) | ||
if err != nil { | ||
return "", fmt.Errorf("fail to write executable: %v", err) | ||
} | ||
if err := f.Chmod(os.ModePerm); err != nil { | ||
return "", fmt.Errorf("fail to chmod: %v", err) | ||
} | ||
return f.Name(), nil | ||
} | ||
|
||
var ( | ||
ffmpegPath string | ||
ffprobePath string | ||
) | ||
|
||
func FFmpegPath() string { return ffmpegPath } | ||
|
||
func FFprobePath() string { return ffprobePath } | ||
|
||
func init() { | ||
var err error | ||
ffmpegPath, err = writeTempExec("ffmpeg_windows_amd64", ffmpeg) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to write ffmpeg_windows_amd64: %v", err)) | ||
} | ||
ffprobePath, err = writeTempExec("ffprobe_windows_amd64", ffprobe) | ||
if err != nil { | ||
panic(fmt.Errorf("failed to write ffprobe_windows_amd64: %v", err)) | ||
} | ||
} |
Git LFS file not shown
Git LFS file not shown