1
0
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:
wdvxdr 2021-08-07 12:04:32 +08:00
parent 3326b2aa2f
commit e506622399
No known key found for this signature in database
GPG Key ID: 703F8C071DE7A1B6
6 changed files with 12 additions and 31 deletions

View File

@ -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")
}

View File

@ -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

View File

@ -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
}

View File

@ -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
View File

@ -0,0 +1,4 @@
package codec
// Debug mode controls the ffmpeg output.
var Debug bool

View File

@ -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{