mirror of
https://github.com/xfrr/goffmpeg.git
synced 2025-10-07 00:43:38 +08:00
Print nothing if no progress tracking is being done
This commit is contained in:
@@ -3,6 +3,7 @@ package test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
"github.com/xfrr/goffmpeg/transcoder"
|
"github.com/xfrr/goffmpeg/transcoder"
|
||||||
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInputNotFound(t *testing.T) {
|
func TestInputNotFound(t *testing.T) {
|
||||||
@@ -227,3 +228,27 @@ func TestTranscodingWMV(t *testing.T) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTranscodingProgress(t *testing.T) {
|
||||||
|
|
||||||
|
var inputPath = "/data/test.mp4"
|
||||||
|
var outputPath = "/data/testmp4.mp4"
|
||||||
|
|
||||||
|
trans := new(transcoder.Transcoder)
|
||||||
|
|
||||||
|
err := trans.Initialize(inputPath, outputPath)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
done := trans.Run(true)
|
||||||
|
for val := range trans.Output() {
|
||||||
|
fmt.Printf("%+v\n", val)
|
||||||
|
}
|
||||||
|
err = <- done
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -117,7 +117,9 @@ func (t *Transcoder) Initialize(inputPath string, outputPath string) (error) {
|
|||||||
func (t *Transcoder) Run(progress bool) <-chan error {
|
func (t *Transcoder) Run(progress bool) <-chan error {
|
||||||
done := make(chan error)
|
done := make(chan error)
|
||||||
command := t.GetCommand()
|
command := t.GetCommand()
|
||||||
|
if !progress {
|
||||||
|
command = append([]string{"-nostats", "-loglevel", "0"}, command...)
|
||||||
|
}
|
||||||
proc := exec.Command(t.configuration.FfmpegBin, command...)
|
proc := exec.Command(t.configuration.FfmpegBin, command...)
|
||||||
if progress {
|
if progress {
|
||||||
errStream, err := proc.StderrPipe()
|
errStream, err := proc.StderrPipe()
|
||||||
|
Reference in New Issue
Block a user