Support ape audio format
Why not support ape audio format? Ape format is a very important lossless format in the audio playing market. I know that supporting ape format is a necessary job.
It looks like ffmpeg has a decoder for this format, so it might be easy to add support via the ffmpeg extension. Please could you provide some sample media?
One caveat: although adding support for decoding via ffmpeg might be easy, if the container format is not one we support already then it's probably going to be a lot of work.
Through this link http://google.github.io/ExoPlayer/supported-formats.html, this ffmpeg extra extended format does not contain ape, I looked up some information, ffmpeg does not contain the ape format, the format is monkey audio, I need to go to the additional extension of the monkey audio, this seems to be a lot of work. Is my idea right?
I think the two steps required to add support are: implementing an extractor for the format, as it looks like Monkey Audio does have its own container, then updating the ffmpeg extension to expose its libavcodec/apedec.c decoder, which should be easy. It's unlikely we will get round to this soon but please feel free to send a pull request.
Thanks for your patience, I will try to support the ape format, but my opinion is that ExoPlayer should support the ape format
I'm trying to support ape, and now I have a weird problem, naming ffmpeg has included ape format (the value of true at FfmpegLibrary.ffmpegHasDecoder ("ape"), but when executing ffmpegInitialize, the initialization fails, there is a failed Log, you can give some Do you give me an opinion?
04-11 10:11:37.962 5752-5871/com.xiaopeng.musicradio D/FfmpegLibrary: codecName= ape hasDecoder=true
04-11 10:11:37.962 5752-5871/com.xiaopeng.musicradio D/FfmpegLibrary: codecName= ape hasDecoder=true
04-11 10:11:37.962 5752-5752/com.xiaopeng.musicradio D/MediaPlayerModel: [ main,null,onTracksChanged : 223 ] onTracksChanged: com.google.android.exoplayer2.source.TrackGroupArray@27eae99 trackSelections=com.google.android.exoplayer2.trackselection.TrackSelectionArray@ea29e339
04-11 10:11:37.972 5752-5752/com.xiaopeng.musicradio D/EventLogger: Tracks [
04-11 10:11:37.972 5752-5752/com.xiaopeng.musicradio D/EventLogger: Renderer:2 [
04-11 10:11:37.972 5752-5752/com.xiaopeng.musicradio D/EventLogger: Group:0, adaptive_supported=N/A [
04-11 10:11:37.972 5752-5752/com.xiaopeng.musicradio D/EventLogger: [X] Track:0, id=null, mimeType=audio/ape, channels=2, sample_rate=44100, supported=YES
04-11 10:11:37.972 5752-5752/com.xiaopeng.musicradio D/EventLogger: ]
04-11 10:11:37.972 5752-5752/com.xiaopeng.musicradio D/EventLogger: ]
04-11 10:11:37.972 5752-5752/com.xiaopeng.musicradio D/EventLogger: ]
04-11 10:11:38.012 5752-5874/com.xiaopeng.musicradio D/dalvikvm: GC_FOR_ALLOC freed 1873K, 18% free 9212K/11140K, paused 40ms, total 40ms
04-11 10:11:38.012 5752-5752/com.xiaopeng.musicradio D/EventLogger: audioEnabled [0.22]
04-11 10:11:38.012 5752-5871/com.xiaopeng.musicradio E/ffmpeg_jni: Error in avcodec_open2: Invalid argument
04-11 10:11:38.052 5752-5874/com.xiaopeng.musicradio D/dalvikvm: GC_FOR_ALLOC freed 1761K, 24% free 9273K/12084K, paused 33ms, total 33ms
04-11 10:11:38.052 5752-5871/com.xiaopeng.musicradio E/ExoPlayerImplInternal: Renderer error.
com.google.android.exoplayer2.ExoPlaybackException
at com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer.maybeInitDecoder(SimpleDecoderAudioRenderer.java:572)
at com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer.onInputFormatChanged(SimpleDecoderAudioRenderer.java:618)
at com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer.render(SimpleDecoderAudioRenderer.java:230)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:560)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:306)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: com.google.android.exoplayer2.ext.ffmpeg.FfmpegDecoderException: Initialization failed.
at com.google.android.exoplayer2.ext.ffmpeg.FfmpegDecoder.<init>(FfmpegDecoder.java:62)
at com.google.android.exoplayer2.ext.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:106)
at com.google.android.exoplayer2.ext.ffmpeg.FfmpegAudioRenderer.createDecoder(FfmpegAudioRenderer.java:35)
at com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer.maybeInitDecoder(SimpleDecoderAudioRenderer.java:565)
at com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer.onInputFormatChanged(SimpleDecoderAudioRenderer.java:618)
at com.google.android.exoplayer2.audio.SimpleDecoderAudioRenderer.render(SimpleDecoderAudioRenderer.java:230)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:560)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:306)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)
The relevant log line is E/ffmpeg_jni: Error in avcodec_open2: Invalid argument. I suggest looking through the code for that function in libavcodec/utils.c and perhaps adding some more logging to diagnose the cause of the failure.
When is the APE format supported?
This issue is marked low priority. We don't have any plans to add support at the moment.
Thanks for your patience, I will try to support the ape format, but my opinion is that ExoPlayer should support the ape format
Hi,have you implemented support for ape format ?could you provide a demo? thanks
This is Matt Ashland, the author of Monkey's Audio. Just know I would love to see Exo add APE support. The APE SDK builds on Android, but doing it with ffmpeg would be great too. Please write mail at monkeysaudio dot com if you want any help. Thanks.
@tangmingscau Hi, Have you find solution for ape format yet?
Last post was almost a year ago. I would still love to see an APE plugin. Like I said, the APE SDK builds on Android (we do this at JRiver). I'm happy to help if needed. I'm mail at monkeysaudio dot com. Thanks.
how to support ape with ffmpeg? please help me
Hi there,
APE is supported by FFMpeg.
Here are a couple links:
https://askubuntu.com/questions/376684/how-to-use-ffmpeg-to-convert-ape-to-mp3
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/ape.c
Cheers, Matt
Hi there,
APE is supported by FFMpeg.
Here are a couple links:
https://askubuntu.com/questions/376684/how-to-use-ffmpeg-to-convert-ape-to-mp3
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/ape.c
Cheers, Matt
How to make exoplayer support ape? my music player use the exoplayer to play music~~~
That's what I'm asking for here. The APE format has been around for over 20 years and compresses better than any alternative. The APE SDK builds fine on Android. I just need someone to connect the dots.
Hi there,
APE is supported by FFMpeg.
Here are a couple links:
https://askubuntu.com/questions/376684/how-to-use-ffmpeg-to-convert-ape-to-mp3
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/ape.c
Cheers, Matt
Hi Matt,
I developed a new ApeExtractor for ExoPlayer, and proved that it works with media3-lib-decoder-ffmpeg.
I'm currently facing an issue with the APE frame size. My question is: Should I split the APE frame data stored in the file into smaller pieces? Is it possible to split it?
I see that the frame data block is stored in little-endian order and is 4-byte aligned with offset information. It also includes a CRC checksum value and a block count.
The total data bytes in a single frame seem too large for both the input buffer and the output render buffer. For version 3950, the sample blocks can reach up to 73728 * 4 per frame, meaning the raw output size is approximately 1,179,648 bytes for 16-bit stereo audio. Given a compression ratio of about 2.0, the encoded input size is roughly half of that.
If splitting the frame data isn't feasible, we might need to consider increasing the ExoPlayer buffer size as a workaround. However, that feels a bit hacky. We should probably explore more elegant options if possible.
Cheers, Will
Thanks! That's great news!
APE frame size can be kind of large, especially at higher compression levels because that helps compression.
This is the code for blocks per frame: // initialize (creates the base classes) m_nBlocksPerFrame = 73728; if (nCompressionLevel == APE_COMPRESSION_LEVEL_EXTRA_HIGH) m_nBlocksPerFrame *= 4; else if (nCompressionLevel == APE_COMPRESSION_LEVEL_INSANE) m_nBlocksPerFrame *= 16;
Everything really wants to work a block at a time.
Could you extract to a working buffer that you keep yourself then copy out of that into the ExoPlayer buffer?
Does anybody else have any other ideas?
Thanks!