add error msg
This commit is contained in:
parent
3926d8cace
commit
54c98210dd
26
audio.go
26
audio.go
@ -64,7 +64,7 @@ func (self *Resampler) Resample(in av.AudioFrame) (out av.AudioFrame, err error)
|
|||||||
nil, C.int(0), C.int(0),
|
nil, C.int(0), C.int(0),
|
||||||
))
|
))
|
||||||
if convertSamples < 0 {
|
if convertSamples < 0 {
|
||||||
err = fmt.Errorf("avresample_convert_frame failed")
|
err = fmt.Errorf("ffmpeg: avresample_convert_frame failed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
flush.SampleCount = convertSamples
|
flush.SampleCount = convertSamples
|
||||||
@ -129,7 +129,7 @@ func (self *Resampler) Resample(in av.AudioFrame) (out av.AudioFrame, err error)
|
|||||||
(*C.int)(unsafe.Pointer(&inData[0])), C.int(inLinesize), C.int(inSampleCount),
|
(*C.int)(unsafe.Pointer(&inData[0])), C.int(inLinesize), C.int(inSampleCount),
|
||||||
))
|
))
|
||||||
if convertSamples < 0 {
|
if convertSamples < 0 {
|
||||||
err = fmt.Errorf("avresample_convert_frame failed")
|
err = fmt.Errorf("ffmpeg: avresample_convert_frame failed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
out.SampleCount = convertSamples
|
out.SampleCount = convertSamples
|
||||||
@ -291,7 +291,7 @@ func (self *AudioEncoder) encodeOne(frame av.AudioFrame) (gotpkt bool, pkt av.Pa
|
|||||||
}
|
}
|
||||||
cerr := C.avcodec_encode_audio2(ff.codecCtx, &cpkt, ff.frame, &cgotpkt)
|
cerr := C.avcodec_encode_audio2(ff.codecCtx, &cpkt, ff.frame, &cgotpkt)
|
||||||
if cerr < C.int(0) {
|
if cerr < C.int(0) {
|
||||||
err = fmt.Errorf("avcodec_encode_audio2 failed: %d", cerr)
|
err = fmt.Errorf("ffmpeg: avcodec_encode_audio2 failed: %d", cerr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,7 +514,7 @@ func (self *AudioDecoder) Decode(data []byte) (gotframe bool, frame av.AudioFram
|
|||||||
cerr := C.wrap_avcodec_decode_audio4(ff.codecCtx, ff.frame, unsafe.Pointer(&data[0]), C.int(len(data)), &cgotframe)
|
cerr := C.wrap_avcodec_decode_audio4(ff.codecCtx, ff.frame, unsafe.Pointer(&data[0]), C.int(len(data)), &cgotframe)
|
||||||
|
|
||||||
if cerr < C.int(0) {
|
if cerr < C.int(0) {
|
||||||
err = fmt.Errorf("avcodec_decode_audio4 failed: %d", cerr)
|
err = fmt.Errorf("ffmpeg: avcodec_decode_audio4 failed: %d", cerr)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,18 +575,18 @@ func NewAudioEncoderByCodecType(typ int) (enc *AudioEncoder, err error) {
|
|||||||
id = C.AV_CODEC_ID_AAC
|
id = C.AV_CODEC_ID_AAC
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("cannot find encoder codecType=%d", typ)
|
err = fmt.Errorf("ffmpeg: cannot find encoder codecType=%d", typ)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
codec := C.avcodec_find_encoder(id)
|
codec := C.avcodec_find_encoder(id)
|
||||||
if codec == nil {
|
if codec == nil {
|
||||||
err = fmt.Errorf("cannot find encoder codecId=%d", id)
|
err = fmt.Errorf("ffmpeg: cannot find encoder codecId=%d", id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if C.avcodec_get_type(id) != C.AVMEDIA_TYPE_AUDIO {
|
if C.avcodec_get_type(id) != C.AVMEDIA_TYPE_AUDIO {
|
||||||
err = fmt.Errorf("codecId=%d is not audio", id)
|
err = fmt.Errorf("ffmpeg: codecId=%d is not audio", id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -603,11 +603,11 @@ func NewAudioEncoderByName(name string) (enc *AudioEncoder, err error) {
|
|||||||
|
|
||||||
codec := C.avcodec_find_encoder_by_name(C.CString(name))
|
codec := C.avcodec_find_encoder_by_name(C.CString(name))
|
||||||
if codec == nil {
|
if codec == nil {
|
||||||
err = fmt.Errorf("cannot find encoder=%s", name)
|
err = fmt.Errorf("ffmpeg: cannot find encoder=%s", name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if C.avcodec_get_type(codec.id) != C.AVMEDIA_TYPE_AUDIO {
|
if C.avcodec_get_type(codec.id) != C.AVMEDIA_TYPE_AUDIO {
|
||||||
err = fmt.Errorf("encoder=%s type is not audio", name)
|
err = fmt.Errorf("ffmpeg: encoder=%s type is not audio", name)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,7 +628,7 @@ func NewAudioDecoder(codec av.AudioCodecData) (dec *AudioDecoder, err error) {
|
|||||||
_dec.Extradata = aaccodec.MPEG4AudioConfigBytes()
|
_dec.Extradata = aaccodec.MPEG4AudioConfigBytes()
|
||||||
id = C.AV_CODEC_ID_AAC
|
id = C.AV_CODEC_ID_AAC
|
||||||
} else {
|
} else {
|
||||||
err = fmt.Errorf("aac CodecData must be av.AACCodecData")
|
err = fmt.Errorf("ffmpeg: aac CodecData must be av.AACCodecData")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,19 +644,19 @@ func NewAudioDecoder(codec av.AudioCodecData) (dec *AudioDecoder, err error) {
|
|||||||
_dec.Extradata = ffcodec.extradata
|
_dec.Extradata = ffcodec.extradata
|
||||||
id = ffcodec.codecId
|
id = ffcodec.codecId
|
||||||
} else {
|
} else {
|
||||||
err = fmt.Errorf("invalid CodecData for ffmpeg to decode")
|
err = fmt.Errorf("ffmpeg: invalid CodecData for ffmpeg to decode")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c := C.avcodec_find_decoder(id)
|
c := C.avcodec_find_decoder(id)
|
||||||
if c == nil {
|
if c == nil {
|
||||||
err = fmt.Errorf("cannot find decoder id=%d", id)
|
err = fmt.Errorf("ffmpeg: cannot find decoder id=%d", id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if C.avcodec_get_type(c.id) != C.AVMEDIA_TYPE_AUDIO {
|
if C.avcodec_get_type(c.id) != C.AVMEDIA_TYPE_AUDIO {
|
||||||
err = fmt.Errorf("decoder id=%d type is not audio", c.id)
|
err = fmt.Errorf("ffmpeg: decoder id=%d type is not audio", c.id)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user