[Libav-user] Issue with decoding APE files

Michał Kurowski mkurowski at n7mobile.com
Fri Aug 7 15:35:37 CEST 2015


On 2015-08-07 12:55, Nicolas George wrote:
> Unlike video packets, audio packets can decode into multiple frames: you
> have to get the return value of avcodec_decode_audio4(), remove that many
> bytes from the beginning of the packet, and re-call avcodec_decode_audio4()
> until all the packet have been consumed.

	Thank you for the fast reply. Now I understand the issue and it makes sense (my APE files seem to have around 15 frames per packet). Unfortunately I ran into another problem - the return value of avcodec_decode_audio4() equals the packet size when I decode ALAC or FLAC, but when decoding APE, it is always 0, hence my first implementation of the fix resulted in an infinite loop. It seems however that trying to get as many frames as possible until got_frame_ptr is 0 works. So basically, now I try to decode as many frames as I can until:

a) I get an error (didn't happen during tests, but...)
b) got_frame_ptr is 0 (this works for APE)
c) return value of avcodec_decode_audio4() is greater than 0 and equal to Packet.size (this works for ALAC and FLAC)
	I will do some more tests on more audio files and hopefully I will settle on this solution. Thank you for your time and help.

Best regards,

	Michał Kurowski

More information about the Libav-user mailing list