34 lines
484 B
Go
34 lines
484 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"os/exec"
|
||
|
"sync"
|
||
|
|
||
|
"git.milar.in/milarin/channel"
|
||
|
)
|
||
|
|
||
|
var EncodeRunner = channel.NewLimitedRunner(1)
|
||
|
|
||
|
func EncodeVideo2Mp3(inputFile, outputFile string) error {
|
||
|
var err error
|
||
|
|
||
|
wg := &sync.WaitGroup{}
|
||
|
|
||
|
wg.Add(1)
|
||
|
EncodeRunner.Run(func() {
|
||
|
defer wg.Done()
|
||
|
|
||
|
cmd := exec.Command("ffmpeg", "-i", inputFile, "-vn", outputFile)
|
||
|
if err = cmd.Start(); err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
if err = cmd.Wait(); err != nil {
|
||
|
return
|
||
|
}
|
||
|
})
|
||
|
|
||
|
wg.Wait()
|
||
|
return err
|
||
|
}
|