1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

encode mp4

This commit is contained in:
wdvxdr 2021-01-08 14:12:25 +08:00
parent 2d020bc7f7
commit f501b31152
3 changed files with 18 additions and 3 deletions

5
.gitignore vendored
View File

@ -1,2 +1,7 @@
vendor/
.idea
config.hjson
device.json
codec/
data/
logs/

View File

@ -605,7 +605,6 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interf
}
}()
data, err := bot.Client.GetTts(d["text"])
ioutil.WriteFile("tts.silk", data, 777)
if err != nil {
return nil, err
}
@ -620,7 +619,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m interf
return nil, err
}
if !global.IsAMRorSILK(data) {
data, err = global.Encoder(data)
data, err = global.EncoderSilk(data)
if err != nil {
return nil, err
}

View File

@ -7,6 +7,7 @@ import (
"github.com/Mrs4s/go-cqhttp/global/codec"
log "github.com/sirupsen/logrus"
"io/ioutil"
"os/exec"
"path"
)
@ -21,7 +22,7 @@ func InitCodec() {
}
}
func Encoder(data []byte) ([]byte, error) {
func EncoderSilk(data []byte) ([]byte, error) {
if useSilkCodec == false {
return nil, errors.New("no silk encoder")
}
@ -37,3 +38,13 @@ func Encoder(data []byte) ([]byte, error) {
}
return slk, nil
}
func EncodeMP4(src string, dst string) error {
cmd := exec.Command("ffmpeg", "-i", src, "-c", "copy", "-map", "0", dst)
return cmd.Run()
}
func ExtractCover(src string, dst string) error {
cmd := exec.Command("ffmpeg", "-i", src, "-y", "-r", "1", "-f", "image2", dst)
return cmd.Run()
}