Skip to content

Commit 28ddd7a

Browse files
committed
fix: some things and rename pkg
1 parent d91fbf5 commit 28ddd7a

File tree

7 files changed

+46
-91
lines changed

7 files changed

+46
-91
lines changed

.circleci/config.yml

-18
This file was deleted.

.gitignore

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
1-
main.go
2-
build
1+
.idea/
2+
cmake-build-*/
3+
*.iws
4+
out/
5+
.idea_modules/
6+
atlassian-ide-plugin.xml
7+
com_crashlytics_export_strings.xml
8+
crashlytics.properties
9+
crashlytics-build.properties
10+
fabric.properties
11+
*.exe
12+
*.exe~
13+
*.dll
14+
*.so
15+
*.dylib
16+
*.test
17+
*.out

README.md

+8-39
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,10 @@
1-
# Golang Transcoding Library
1+
# Transcoding library in Go
2+
Fork of Floostack's transcoding library.
23

3-
<br />
4-
5-
<div align="center">
6-
<!-- Build status -->
7-
<a href="https://circleci.com/gh/floostack/transcoder">
8-
<img src="https://circleci.com/gh/floostack/transcoder.svg?style=svg" alt="Build Status" />
9-
</a>
10-
11-
<!-- Code Quality -->
12-
<a href="https://www.codacy.com/manual/floostack/transcoder?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=floostack/transcoder&amp;utm_campaign=Badge_Grade">
13-
<img src="https://app.codacy.com/project/badge/Grade/f8ee19ef723b4134bb8bb1f9c439959e" alt="Build Status" />
14-
</a>
15-
16-
</div>
17-
18-
<br />
19-
20-
<div align="center">
21-
<sub>Created by <a href="https://floostack.com">FlooStack</a>.</sub>
22-
</div>
23-
24-
## Features
25-
26-
<dl>
27-
<dt>Ease use</dt>
28-
<dd>Implement your own business logic around easy interfaces</dd>
29-
30-
<dt>Transcoding progress</dt>
31-
<dd>Obtain progress events generated by transcoding application process</dd>
32-
</dl>
33-
34-
## Download from Github
4+
## Download from GitHub
355

366
```shell
37-
go get github.com/floostack/transcoder
7+
go get github.com/SumeruCCTV/transcoder
388
```
399

4010
## Example
@@ -45,20 +15,19 @@ package main
4515
import (
4616
"log"
4717

48-
ffmpeg "github.com/floostack/transcoder/ffmpeg"
18+
ffmpeg "github.com/SumeruCCTV/transcoder/ffmpeg"
4919
)
5020

5121
func main() {
5222

53-
5423
hwaccel := "cuvid"
5524
videoCodec := "h264_cuvid"
5625

5726
inputOpts := ffmpeg.Options{
58-
Hwaccel: &hwaccel,
59-
VideoCodec: &videoCodec,
27+
Hwaccel: &hwaccel,
28+
VideoCodec: &videoCodec,
6029
}
61-
30+
6231
format := "mp4"
6332
overwrite := true
6433

ffmpeg/ffmpeg.go

+18-29
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414
"strconv"
1515
"strings"
1616

17-
"github.com/floostack/transcoder"
18-
"github.com/floostack/transcoder/utils"
17+
"github.com/SumeruCCTV/transcoder"
18+
"github.com/SumeruCCTV/transcoder/utils"
1919
)
2020

2121
// Transcoder ...
@@ -40,11 +40,7 @@ func New(cfg *Config) transcoder.Transcoder {
4040

4141
// Start ...
4242
func (t *Transcoder) Start() (<-chan transcoder.Progress, error) {
43-
4443
var stderrIn io.ReadCloser
45-
46-
out := make(chan transcoder.Progress)
47-
4844
defer t.closePipes()
4945

5046
// Validates config
@@ -101,7 +97,7 @@ func (t *Transcoder) Start() (<-chan transcoder.Progress, error) {
10197
cmd = exec.CommandContext(*t.commandContext, t.config.FfmpegBinPath, args...)
10298
}
10399

104-
// If progresss enabled, get stderr pipe and start progress process
100+
// If progress is enabled, get stderr pipe and start progress process
105101
if t.config.ProgressEnabled && !t.config.Verbose {
106102
stderrIn, err = cmd.StderrPipe()
107103
if err != nil {
@@ -120,19 +116,13 @@ func (t *Transcoder) Start() (<-chan transcoder.Progress, error) {
120116
}
121117

122118
if t.config.ProgressEnabled && !t.config.Verbose {
123-
go func() {
124-
t.progress(stderrIn, out)
125-
}()
126-
127-
go func() {
128-
defer close(out)
129-
err = cmd.Wait()
130-
}()
131-
} else {
132-
err = cmd.Wait()
119+
out := make(chan transcoder.Progress)
120+
defer close(out)
121+
go t.progress(stderrIn, out)
122+
return out, cmd.Wait()
133123
}
134124

135-
return out, nil
125+
return nil, cmd.Wait()
136126
}
137127

138128
// Input ...
@@ -149,7 +139,7 @@ func (t *Transcoder) Output(arg string) transcoder.Transcoder {
149139

150140
// InputPipe ...
151141
func (t *Transcoder) InputPipe(w *io.WriteCloser, r *io.ReadCloser) transcoder.Transcoder {
152-
if &t.input == nil {
142+
if len(t.input) == 0 {
153143
t.inputPipeWriter = w
154144
t.inputPipeReader = r
155145
}
@@ -158,7 +148,7 @@ func (t *Transcoder) InputPipe(w *io.WriteCloser, r *io.ReadCloser) transcoder.T
158148

159149
// OutputPipe ...
160150
func (t *Transcoder) OutputPipe(w *io.WriteCloser, r *io.ReadCloser) transcoder.Transcoder {
161-
if &t.output == nil {
151+
if len(t.output) == 0 {
162152
t.outputPipeWriter = w
163153
t.outputPipeReader = r
164154
}
@@ -267,7 +257,6 @@ func (t *Transcoder) GetMetadata() (transcoder.Metadata, error) {
267257

268258
// progress sends through given channel the transcoding status
269259
func (t *Transcoder) progress(stream io.ReadCloser, out chan transcoder.Progress) {
270-
271260
defer stream.Close()
272261

273262
split := func(data []byte, atEOF bool) (advance int, token []byte, spliterror error) {
@@ -296,7 +285,7 @@ func (t *Transcoder) progress(stream io.ReadCloser, out chan transcoder.Progress
296285
scanner.Buffer(buf, bufio.MaxScanTokenSize)
297286

298287
for scanner.Scan() {
299-
Progress := new(Progress)
288+
progress := new(Progress)
300289
line := scanner.Text()
301290

302291
if strings.Contains(line, "time=") && strings.Contains(line, "bitrate=") {
@@ -338,15 +327,15 @@ func (t *Transcoder) progress(stream io.ReadCloser, out chan transcoder.Progress
338327
timesec := utils.DurToSec(currentTime)
339328
dursec, _ := strconv.ParseFloat(t.metadata.GetFormat().GetDuration(), 64)
340329

341-
progress := (timesec * 100) / dursec
342-
Progress.Progress = progress
330+
currentProgress := (timesec * 100) / dursec
331+
progress.Progress = currentProgress
343332

344-
Progress.CurrentBitrate = currentBitrate
345-
Progress.FramesProcessed = framesProcessed
346-
Progress.CurrentTime = currentTime
347-
Progress.Speed = currentSpeed
333+
progress.CurrentBitrate = currentBitrate
334+
progress.FramesProcessed = framesProcessed
335+
progress.CurrentTime = currentTime
336+
progress.Speed = currentSpeed
348337

349-
out <- *Progress
338+
out <- *progress
350339
}
351340
}
352341
}

ffmpeg/metadata.go

+1-1
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/SumeruCCTV/transcoder"
44

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

ffmpeg/options.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (opts Options) GetStrArguments() []string {
102102
values = append(values, k, fmt.Sprintf("%v", v))
103103
}
104104
}
105-
105+
106106
if vi, ok := value.(*int); ok {
107107
values = append(values, flag, fmt.Sprintf("%d", *vi))
108108
}

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
module github.com/floostack/transcoder
1+
module github.com/SumeruCCTV/transcoder
22

33
go 1.13

0 commit comments

Comments
 (0)