Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Commit aad936c

Browse files
committed
update
1 parent 3106f44 commit aad936c

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
## Download from Github
3535

3636
```shell
37-
go get github.com/floostack/transcoder
37+
go get github.com/admpub/transcoder
3838
```
3939

4040
## Example
@@ -45,7 +45,7 @@ package main
4545
import (
4646
"log"
4747

48-
ffmpeg "github.com/floostack/transcoder/ffmpeg"
48+
ffmpeg "github.com/admpub/transcoder/ffmpeg"
4949
)
5050

5151
func main() {

ffmpeg/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package ffmpeg
22

3+
import "github.com/admpub/transcoder"
4+
35
// Config ...
46
type Config struct {
57
FfmpegBinPath string
68
FfprobeBinPath string
79
ProgressEnabled bool
810
Verbose bool
11+
Env []string
12+
Dir string
13+
OnMetadata func(transcoder.Metadata) error
914
}

ffmpeg/ffmpeg.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"strconv"
1414
"strings"
1515

16-
"github.com/floostack/transcoder"
17-
"github.com/floostack/transcoder/utils"
16+
"github.com/admpub/transcoder"
17+
"github.com/admpub/transcoder/utils"
1818
)
1919

2020
// Transcoder ...
@@ -50,10 +50,15 @@ func (t *Transcoder) Start(opts transcoder.Options) (<-chan transcoder.Progress,
5050
}
5151

5252
// Get file metadata
53-
_, err := t.GetMetadata()
53+
metadata, err := t.GetMetadata()
5454
if err != nil {
5555
return nil, err
5656
}
57+
if t.config.OnMetadata != nil {
58+
if err := t.config.OnMetadata(metadata); err != nil {
59+
return nil, err
60+
}
61+
}
5762

5863
// Append input file and standard options
5964
args := append([]string{"-i", t.input}, opts.GetStrArguments()...)
@@ -83,6 +88,8 @@ func (t *Transcoder) Start(opts transcoder.Options) (<-chan transcoder.Progress,
8388

8489
// Initialize command
8590
cmd := exec.Command(t.config.FfmpegBinPath, args...)
91+
cmd.Env = append(t.config.Env, os.Environ()...)
92+
cmd.Dir = t.config.Dir
8693

8794
// If progresss enabled, get stderr pipe and start progress process
8895
if t.config.ProgressEnabled && !t.config.Verbose {
@@ -192,7 +199,7 @@ func (t *Transcoder) validate() error {
192199
}
193200

194201
// GetMetadata Returns metadata for the specified input file
195-
func (t *Transcoder) GetMetadata() ( transcoder.Metadata, error) {
202+
func (t *Transcoder) GetMetadata() (transcoder.Metadata, error) {
196203

197204
if t.config.FfprobeBinPath != "" {
198205
var outb, errb bytes.Buffer
@@ -208,6 +215,8 @@ func (t *Transcoder) GetMetadata() ( transcoder.Metadata, error) {
208215
cmd := exec.Command(t.config.FfprobeBinPath, args...)
209216
cmd.Stdout = &outb
210217
cmd.Stderr = &errb
218+
cmd.Env = append(t.config.Env, os.Environ()...)
219+
cmd.Dir = t.config.Dir
211220

212221
err := cmd.Run()
213222
if err != nil {

ffmpeg/metadata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package ffmpeg
22

3-
import "github.com/floostack/transcoder"
3+
import "github.com/admpub/transcoder"
44

55
// Metadata ...
66
type Metadata struct {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module github.com/floostack/transcoder
1+
module github.com/admpub/transcoder
22

33
go 1.13

0 commit comments

Comments
 (0)