Adjusted display of error text when an error occurs during video conversion.
This commit is contained in:
parent
dddbfa65bc
commit
176189c9d0
@ -3,6 +3,7 @@ package convertor
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -46,23 +47,12 @@ func (s Service) RunConvert(setting ConvertSetting) error {
|
|||||||
//args := "-report -n -i " + setting.VideoFileInput.Path + " -c:v libx264 -progress unix://" + setting.SocketPath + " output-file.mp4"
|
//args := "-report -n -i " + setting.VideoFileInput.Path + " -c:v libx264 -progress unix://" + setting.SocketPath + " output-file.mp4"
|
||||||
//args := "-n -i " + setting.VideoFileInput.Path + " -c:v libx264 -progress unix://" + setting.SocketPath + " output-file.mp4"
|
//args := "-n -i " + setting.VideoFileInput.Path + " -c:v libx264 -progress unix://" + setting.SocketPath + " output-file.mp4"
|
||||||
args := "-y -i " + setting.VideoFileInput.Path + " -c:v libx264 -progress unix://" + setting.SocketPath + " output-file.mp4"
|
args := "-y -i " + setting.VideoFileInput.Path + " -c:v libx264 -progress unix://" + setting.SocketPath + " output-file.mp4"
|
||||||
cmd := exec.Command("ffmpeg", strings.Split(args, " ")...)
|
cmd := exec.Command(s.pathFFmpeg, strings.Split(args, " ")...)
|
||||||
|
|
||||||
//stderr, _ := cmd.StdoutPipe()
|
out, err := cmd.CombinedOutput()
|
||||||
err := cmd.Start()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
errStringArr := regexp.MustCompile("\r?\n").Split(strings.TrimSpace(string(out)), -1)
|
||||||
}
|
return errors.New(errStringArr[len(errStringArr)-1])
|
||||||
|
|
||||||
//scanner := bufio.NewScanner(stderr)
|
|
||||||
////scanner.Split(bufio.ScanWords)
|
|
||||||
//for scanner.Scan() {
|
|
||||||
// m := scanner.Text()
|
|
||||||
// fmt.Println(m)
|
|
||||||
//}
|
|
||||||
err = cmd.Wait()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user