mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
feat(codec): enhance ffmpeg output with debug.
This commit is contained in:
parent
3326b2aa2f
commit
e506622399
@ -29,6 +29,10 @@ func EncodeToSilk(record []byte, tempName string, useCache bool) (silkWav []byte
|
||||
// 2.转换pcm
|
||||
pcmPath := path.Join(silkCachePath, tempName+".pcm")
|
||||
cmd := exec.Command("ffmpeg", "-i", rawPath, "-f", "s16le", "-ar", "24000", "-ac", "1", pcmPath)
|
||||
if Debug {
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
}
|
||||
if err = cmd.Run(); err != nil {
|
||||
return nil, errors.Wrap(err, "convert pcm file error")
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//go:build (!arm && !arm64 && !amd64 && !386) || race
|
||||
// +build !arm,!arm64,!amd64,!386 race
|
||||
//go:build (!arm && !arm64 && !amd64 && !386) || race || (!windows && !linux && !darwin) || (windows && arm)
|
||||
// +build !arm,!arm64,!amd64,!386 race !windows,!linux,!darwin windows,arm
|
||||
|
||||
package codec
|
||||
|
@ -1,16 +0,0 @@
|
||||
//go:build !windows && !linux && !darwin
|
||||
// +build !windows,!linux,!darwin
|
||||
|
||||
package codec
|
||||
|
||||
import "errors"
|
||||
|
||||
// EncodeToSilk 将音频编码为Silk
|
||||
func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) {
|
||||
return nil, errors.New("not supported now")
|
||||
}
|
||||
|
||||
// RecodeTo24K 将silk重新编码为 24000 bit rate
|
||||
func RecodeTo24K(data []byte) []byte {
|
||||
return data
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
package codec
|
||||
|
||||
import "errors"
|
||||
|
||||
// EncodeToSilk 将音频编码为Silk
|
||||
func EncodeToSilk(record []byte, tempName string, useCache bool) ([]byte, error) {
|
||||
return nil, errors.New("not supported now")
|
||||
}
|
||||
|
||||
// RecodeTo24K 将silk重新编码为 24000 bit rate
|
||||
func RecodeTo24K(data []byte) []byte {
|
||||
return data
|
||||
}
|
4
global/codec/stubs.go
Normal file
4
global/codec/stubs.go
Normal file
@ -0,0 +1,4 @@
|
||||
package codec
|
||||
|
||||
// Debug mode controls the ffmpeg output.
|
||||
var Debug bool
|
2
main.go
2
main.go
@ -19,6 +19,7 @@ import (
|
||||
|
||||
"github.com/Mrs4s/go-cqhttp/coolq"
|
||||
"github.com/Mrs4s/go-cqhttp/global"
|
||||
"github.com/Mrs4s/go-cqhttp/global/codec"
|
||||
"github.com/Mrs4s/go-cqhttp/global/config"
|
||||
"github.com/Mrs4s/go-cqhttp/global/terminal"
|
||||
"github.com/Mrs4s/go-cqhttp/global/update"
|
||||
@ -79,6 +80,7 @@ func main() {
|
||||
}
|
||||
if conf.Output.Debug {
|
||||
log.SetReportCaller(true)
|
||||
codec.Debug = true
|
||||
}
|
||||
|
||||
logFormatter := &easy.Formatter{
|
||||
|
Loading…
x
Reference in New Issue
Block a user