mirror of
https://github.com/navidrome/navidrome.git
synced 2025-12-23 23:18:05 -05:00
refactor(server): remove ffmpeg unused code
This commit is contained in:
@@ -18,8 +18,6 @@ import (
|
|||||||
type FFmpeg interface {
|
type FFmpeg interface {
|
||||||
Transcode(ctx context.Context, command, path string, maxBitRate, offset int) (io.ReadCloser, error)
|
Transcode(ctx context.Context, command, path string, maxBitRate, offset int) (io.ReadCloser, error)
|
||||||
ExtractImage(ctx context.Context, path string) (io.ReadCloser, error)
|
ExtractImage(ctx context.Context, path string) (io.ReadCloser, error)
|
||||||
ConvertToWAV(ctx context.Context, path string) (io.ReadCloser, error)
|
|
||||||
ConvertToFLAC(ctx context.Context, path string) (io.ReadCloser, error)
|
|
||||||
Probe(ctx context.Context, files []string) (string, error)
|
Probe(ctx context.Context, files []string) (string, error)
|
||||||
CmdPath() (string, error)
|
CmdPath() (string, error)
|
||||||
IsAvailable() bool
|
IsAvailable() bool
|
||||||
@@ -33,8 +31,6 @@ func New() FFmpeg {
|
|||||||
const (
|
const (
|
||||||
extractImageCmd = "ffmpeg -i %s -an -vcodec copy -f image2pipe -"
|
extractImageCmd = "ffmpeg -i %s -an -vcodec copy -f image2pipe -"
|
||||||
probeCmd = "ffmpeg %s -f ffmetadata"
|
probeCmd = "ffmpeg %s -f ffmetadata"
|
||||||
createWavCmd = "ffmpeg -i %s -c:a pcm_s16le -f wav -"
|
|
||||||
createFLACCmd = "ffmpeg -i %s -f flac -"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ffmpeg struct{}
|
type ffmpeg struct{}
|
||||||
@@ -55,16 +51,6 @@ func (e *ffmpeg) ExtractImage(ctx context.Context, path string) (io.ReadCloser,
|
|||||||
return e.start(ctx, args)
|
return e.start(ctx, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ffmpeg) ConvertToWAV(ctx context.Context, path string) (io.ReadCloser, error) {
|
|
||||||
args := createFFmpegCommand(createWavCmd, path, 0, 0)
|
|
||||||
return e.start(ctx, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *ffmpeg) ConvertToFLAC(ctx context.Context, path string) (io.ReadCloser, error) {
|
|
||||||
args := createFFmpegCommand(createFLACCmd, path, 0, 0)
|
|
||||||
return e.start(ctx, args)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *ffmpeg) Probe(ctx context.Context, files []string) (string, error) {
|
func (e *ffmpeg) Probe(ctx context.Context, files []string) (string, error) {
|
||||||
if _, err := ffmpegCmd(); err != nil {
|
if _, err := ffmpegCmd(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -167,7 +153,6 @@ func createFFmpegCommand(cmd, path string, maxBitRate, offset int) []string {
|
|||||||
args = append(args, s)
|
args = append(args, s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return args
|
return args
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,16 +172,13 @@ func createProbeCommand(cmd string, inputs []string) []string {
|
|||||||
|
|
||||||
func fixCmd(cmd string) []string {
|
func fixCmd(cmd string) []string {
|
||||||
split := strings.Split(cmd, " ")
|
split := strings.Split(cmd, " ")
|
||||||
var result []string
|
|
||||||
cmdPath, _ := ffmpegCmd()
|
cmdPath, _ := ffmpegCmd()
|
||||||
for _, s := range split {
|
for i, s := range split {
|
||||||
if s == "ffmpeg" || s == "ffmpeg.exe" {
|
if s == "ffmpeg" || s == "ffmpeg.exe" {
|
||||||
result = append(result, cmdPath)
|
split[i] = cmdPath
|
||||||
} else {
|
|
||||||
result = append(result, s)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result
|
return split
|
||||||
}
|
}
|
||||||
|
|
||||||
func ffmpegCmd() (string, error) {
|
func ffmpegCmd() (string, error) {
|
||||||
|
|||||||
@@ -37,20 +37,6 @@ func (ff *MockFFmpeg) ExtractImage(context.Context, string) (io.ReadCloser, erro
|
|||||||
return ff, nil
|
return ff, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ff *MockFFmpeg) ConvertToFLAC(context.Context, string) (io.ReadCloser, error) {
|
|
||||||
if ff.Error != nil {
|
|
||||||
return nil, ff.Error
|
|
||||||
}
|
|
||||||
return ff, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ff *MockFFmpeg) ConvertToWAV(context.Context, string) (io.ReadCloser, error) {
|
|
||||||
if ff.Error != nil {
|
|
||||||
return nil, ff.Error
|
|
||||||
}
|
|
||||||
return ff, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ff *MockFFmpeg) Probe(context.Context, []string) (string, error) {
|
func (ff *MockFFmpeg) Probe(context.Context, []string) (string, error) {
|
||||||
if ff.Error != nil {
|
if ff.Error != nil {
|
||||||
return "", ff.Error
|
return "", ff.Error
|
||||||
|
|||||||
Reference in New Issue
Block a user