49 lines
1.0 KiB
Go
49 lines
1.0 KiB
Go
package ffmpeg
|
|
|
|
import "errors"
|
|
|
|
var (
|
|
ErrInvalidInput = errors.New("invalid input")
|
|
ErrInvalidOutput = errors.New("invalid output")
|
|
ErrCodecNotFound = errors.New("codec not found")
|
|
ErrFormatNotSupported = errors.New("format not supported")
|
|
ErrDecodeFailed = errors.New("decode failed")
|
|
ErrEncodeFailed = errors.New("encode failed")
|
|
ErrFilterFailed = errors.New("filter failed")
|
|
ErrIOFailed = errors.New("I/O operation failed")
|
|
ErrNoStream = errors.New("no stream found")
|
|
ErrInvalidCodec = errors.New("invalid codec")
|
|
)
|
|
|
|
// FFmpegError wraps FFmpeg errors with additional context
|
|
type FFmpegError struct {
|
|
Code int
|
|
Message string
|
|
Op string
|
|
}
|
|
|
|
func (e *FFmpegError) Error() string {
|
|
return e.Op + ": " + e.Message + " (code: " + itoa(e.Code) + ")"
|
|
}
|
|
|
|
func itoa(n int) string {
|
|
if n < 0 {
|
|
return "-" + uitoa(uint(-n))
|
|
}
|
|
return uitoa(uint(n))
|
|
}
|
|
|
|
func uitoa(n uint) string {
|
|
if n == 0 {
|
|
return "0"
|
|
}
|
|
var buf [20]byte
|
|
i := len(buf)
|
|
for n > 0 {
|
|
i--
|
|
buf[i] = byte('0' + n%10)
|
|
n /= 10
|
|
}
|
|
return string(buf[i:])
|
|
}
|