Android MediaCodec AAC Decoding Fails on API 23 - android

I'm decoding AAC (m4a) audio using MediaCodec and MediaExtractor using the async model. It works great on a Pixel, Pixel 3A and Samsung S22 Ultra, but fails after calling queueInputBuffer() the first time on an HTC M8 running Android 6 and API 23 emulator.
Codec configuration:
MediaFormat inputFormat = _extractor.getTrackFormat(0);
inputFormat.setInteger(MediaFormat.KEY_MAX_INPUT_SIZE, 16384);
String mimeType = inputFormat.getString(MediaFormat.KEY_MIME);
_decoder = MediaCodec.createDecoderByType(mimeType);
_decoder.configure(inputFormat, null, null, 0);
Logs from the MTC M8:
2023-01-18 07:10:27.4484|TRACE|AudioDecoder..ctor [1] Audio input format: {aac-profile=2, mime=audio/mp4a-latm, channel-count=2, max-input-size=738, durationUs=217478095, csd-0=java.nio.ByteArrayBuffer[position=0,limit=5,capacity=5], encoder-delay=2624, encoder-padding=301, sample-rate=44100}
[OMXMaster] A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
[OMXMaster] Failed to get omx plugin handle
2023-01-18 07:10:27.5186|TRACE|AudioDecoder..ctor [1] Decoding audio using OMX.google.aac.decoder
2023-01-18 07:10:27.5504|TRACE|AudioDecoder.OnInputBufferAvailable [1] - - - - - - - - - - Getting input buffer for index 1 - - - - - - - - - -
2023-01-18 07:10:27.5616|TRACE|AudioDecoder.OnInputBufferAvailable [1] - - - - - - - - - - Clearing input buffer for index 1 - - - - - - - - - -
2023-01-18 07:10:27.5706|TRACE|AudioDecoder.OnInputBufferAvailable [1] - - - - - - - - - - Queueing buffer for index 1 - - - - - - - - - -
[SoftAAC2] bytesValid[0] != 0 should never happen
[ACodec] [OMX.google.aac.decoder] ERROR(0x80001001)
[ACodec] signalError(omxError 0x80001001, internalError -2147483648)
[MediaCodec] Codec reported err 0x80001001, actionCode 0, while in state 6
2023-01-18 07:10:27.5706|TRACE|AudioDecoder.OnInputBufferAvailable [1] - - - - - - - - - - Stopped after filling one buffer - - - - - - - - - -
2023-01-18 07:10:27.5874|ERROR|AudioDecoder.OnError [1] Audio decoding failed
Android.Media.MediaCodec+CodecException: Error 0x80001001
--- End of managed Android.Media.MediaCodec+CodecException stack trace ---
android.media.MediaCodec$CodecException: Error 0x80001001
Logs from the API 23 emulator:
2023-01-18 07:21:37.5746|TRACE|AudioDecoder..ctor [1] Audio input format: {aac-profile=2, mime=audio/mp4a-latm, channel-count=2, max-input-size=738, durationUs=217478095, csd-0=java.nio.ByteArrayBuffer[position=0,limit=5,capacity=5], encoder-delay=2624, encoder-padding=301, sample-rate=44100}
[OMXClient] Using client-side OMX mux.
2023-01-18 07:21:37.6093|TRACE|AudioDecoder..ctor [1] Decoding audio using OMX.google.aac.decoder
[MediaCodec] MediaCodec will operate in async mode
2023-01-18 07:21:37.6399|TRACE|AudioDecoder.OnInputBufferAvailable [1] - - - - - - - - - - Getting input buffer for index 1 - - - - - - - - - -
2023-01-18 07:21:37.6475|TRACE|AudioDecoder.OnInputBufferAvailable [1] - - - - - - - - - - Clearing input buffer for index 1 - - - - - - - - - -
2023-01-18 07:21:37.6475|TRACE|AudioDecoder.OnInputBufferAvailable [1] - - - - - - - - - - Queueing buffer for index 1 - - - - - - - - - -
[ACodec] [OMX.google.aac.decoder] ERROR(0x80001001)
[ACodec] signalError(omxError 0x80001001, internalError -2147483648)
[MediaCodec] Codec reported err 0x80001001, actionCode 0, while in state 6
2023-01-18 07:21:37.6576|TRACE|AudioDecoder.OnInputBufferAvailable [1] - - - - - - - - - - Stopped after filling one buffer - - - - - - - - - -
2023-01-18 07:21:37.6668|ERROR|AudioDecoder.OnError [1] Audio decoding failed
Android.Media.MediaCodec+CodecException: Error 0x80001001
--- End of managed Android.Media.MediaCodec+CodecException stack trace ---
android.media.MediaCodec$CodecException: Error 0x80001001
I've tried changing the KEY_MAX_INPUT_SIZE value and omitting it altogether. I've tried different audio files. The files play fine in the built in audio player. I found the error from the M8 here, but didn't find it very helpful. I'd appreciate any help, thank you!
Update:
I'm filling the input buffer by calling MediaExtractor.readSampleData() in a loop and I know I wasn't filling the buffer beyond it's capacity. But on the MTC M8 I did find that if I only fill the input buffer 8 times (the sample is between 464 and 718 bytes) everything works fine. Without setting KEY_MAX_INPUT_SIZE the input buffer's capacity is 8196, so even at the maximum sample size this only fills the buffer ~70%. If I fill it 9 times, the process fails with the above mentioned error.
So now my question becomes, how do you determine how much data to put into the input buffers? Filling each buffer a single time from the MediaExtractor each time onInputBufferAvailable is called makes the process very slow, but apparently you can't fill them entirely.

Related

Qt Android returns Invalid audio format

I have a Qt code with a QSound object that is supposed to read two wav files on a thread.
My code works on iOS simulator, but not on Android.
My thread code that reads wav files :
ClickThread::ClickThread(): highClickFile("://high_click.wav"), lowClickFile("://low_click.wav"), isRunning(false)
{
this->highClick = new QSound(highClickFile);
this->lowClick = new QSound(lowClickFile);
this->setPeriod(120);
}
void ClickThread::process(){
while(this->isRunning == true)
{ if(!this->isRunning) break;
highClick->play();
QThread::msleep(period);
highClick->stop();
if(!this->isRunning) break;
lowClick->play();
QThread::msleep(period);
lowClick->stop();
if(!this->isRunning) break;
lowClick->play();
QThread::msleep(period);
lowClick->stop();
if(!this->isRunning) break;
lowClick->play();
QThread::msleep(period);
lowClick->stop();
}
}
There is the error message I got :
W linker : Warning: "/data/data/org.qtproject.example.MyProject/qt-reserved-files/plugins/audio/libqtaudio_opensles.so" has unsupported flags DT_FLAGS_1=0x80 (ignoring unsupported flags)
D : PlayerBase::PlayerBase()
D : TrackPlayerBase::TrackPlayerBase()
I libOpenSLES: Emulating old channel mask behavior (ignoring positional mask 0x4, using default mask 0x1 based on channel count of 1)
I AudioTrack: createTrack_l(0): AUDIO_OUTPUT_FLAG_FAST successful; frameCount 0 -> 1322
E android.media.AudioTrack: getMinBufferSize(): Invalid audio format.
W libc : malloc(4294967292) failed: returning null pointer
F libc : /Volumes/Android/buildbot/src/android/ndk-release-r20/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:73: abort_message: assertion "terminating with uncaught exception of type std::bad_alloc: std::bad_alloc" failed
F libc : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 7670 (QtThread), pid 6740 (.MyProject)
Thanks for your answers
P
EDIT :
The problem was that my wav file was encoded in 24 bits. Android doesn't seem to use this kind of encoding for PCM files, referring to this website :
https://developer.android.com/reference/android/media/AudioFormat
we only can have 8, 16 or 32 bits.
So, I used FFmpeg to encode my wav files in 16 bits and now my code works !
Check that link for an exemple of encoding with FFmpeg :
ffmpeg FLAC 24 bit 96khz to 16 bit 48khz
Pierre.

Android Things Image on CM3

I am trying to get a Android Things Image to boot on the Compute Module 3.
I have gone through several trial and error to try and get a working image. Currently I sit in the Kernel after getting through the DTB problem I was originally facing.
I use dd to flash the image through RPIBOOT, I validate the pi fully works with Raspian.
This is what I see in the serial console:
MMC: mmc#7e300000: 0
reading uboot.env
In: serial
Out: serial
Err: serial
Net: Net Initialization Skipped
No ethernet found.
ANDROID: Attempting slot b, tries remaining 6
ANDROID: Booting slot: b
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
ANDROID: reboot reason: "(none)"
** Invalid Android Image header **
Android boot failed, error -1.
resetting ...
U-�MMC: mmc#7e300000: 0
reading uboot.env
In: serial
Out: serial
Err: serial
Net: Net Initialization Skipped
No ethernet found.
ANDROID: Attempting slot a, tries remaining 5
ANDROID: Booting slot: a
72 bytes read in 31 ms (2 KiB/s)
ANDROID: reboot reason: "(none)"
Booting kernel at 0x1000000 with fdt at 2efe8600...
## Booting Android Image at 0x01000000 ...
Kernel load addr 0x01000800 size 8385 KiB
Kernel command line: buildvariant=userdebug
RAM disk load addr 0x11000000 size 4947 KiB
## Flattened Device Tree blob at 2efe8600
Booting using the fdt blob at 0x2efe8600
XIP Kernel Image ... OK
Loading Ramdisk to 2cb2b000, end 2cfffb11 ... OK
reserving fdt memory region: addr=0 size=1000
reserving fdt memory region: addr=2efe8600 size=ba00
Loading Device Tree to 2dff1000, end 2dfff9ff ... OK
Starting kernel ...
Note The file system can't be mounted:
ANDROID: Attempting slot b, tries remaining 6
ANDROID: Booting slot: b
Failed to mount ext2 filesystem...
It will sit there forever. I have a feeling it is still something is wrongs with the Device Tree Blob that got me here. I also know the image is okay because I can boot it on a PI 3 B
I have tried both a CM3L and CM.
Both do the same thing and respond the same to the changes so I'm fairly confident that it is not a eMMC vs SD issue.
Does anyone have any thoughts on how I could debug this? Or even better a resource I can utilize to find the Android Things Kernel code for PI?

Cannot record the screen on Android Nexus 4 with screenrecord or telecine

On Nexus 4, with Android 5.1.1 I have the following problem that drives me mad:
When trying to record the screen (on Kubuntu 15.04) with:
adb shell screenrecord --verbose /sdcard/Download/intro9.mp4
just few seconds (1-4) are recorded and then recording stops by itself.
In the logcat there is relevant output:
09-16 14:12:46.943 5733-5742/? I/OMXClient﹕ Using client-side OMX mux.
09-16 14:12:46.946 188-4537/? E/OMX-VENC-720p﹕ Is component secure 0
09-16 14:12:46.969 188-188/? E/OMX-VENC-720p﹕ set_parameter: metamode is valid for input port only
09-16 14:12:46.969 188-188/? E/OMXNodeInstance﹕ setParameter(50:qcom.encoder.avc, OMX.google.android.index.storeMetaDataInBuffers(0x7f00001c): Output:1 en=0 GB=0) ERROR: UnsupportedSetting(0x80001019)
09-16 14:12:46.969 5733-5742/? E/ACodec﹕ [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -1010
09-16 14:12:46.971 188-4537/? E/OMX-VENC-720p﹕ WARNING: Unsupported Color format [2130708361]
09-16 14:12:46.972 188-4537/? E/OMX-VENC-720p﹕ C2D init is successful
09-16 14:12:46.972 188-188/? E/OMX-VENC-720p﹕ WARNING: Unsupported Color format [2130708361]
09-16 14:12:46.973 188-5092/? E/OMX-VENC-720p﹕ venc_set_intra_period: nPFrames = 600 nBFrames = 0
09-16 14:12:46.982 188-5743/? E/OMX-VENC-720p﹕ Allocated virt:0xb3e4b000, FD: 41 of size 1474560 at index: 0
09-16 14:12:46.982 188-5743/? E/OMX-VENC-720p﹕ Allocated virt:0xb3ce3000, FD: 43 of size 1474560 at index: 1
09-16 14:12:47.011 188-5743/? E/OMX-VENC-720p﹕ open Color conv for RGBA888
After Ctrl-C:
09-16 14:13:21.482 188-716/? E/OMX-VENC-720p﹕ ion recon buffer free failed
09-16 14:13:21.482 188-716/? E/OMX-VENC-720p﹕ ion recon buffer free failed
09-16 14:13:21.521 188-5744/? E/OMX-VENC-720p﹕ ioctl VEN_IOCTL_CMD_READ_NEXT_MSG failed
09-16 14:13:21.521 188-5092/? E/OMX-VENC-720p﹕ Destroy C2D instance
The console outpus is:
Main display is 768x1280 #60.00fps (orientation=0)
Configuring recorder for 768x1280 video/avc at 4.00Mbps
Content area is 768x1280 at offset x=0 y=0
I've tried different solutions like lowering the bitrate, restarting the phone, using telecine, using different PC, turning off MTP but with no luck. In the past when faced the same problem even downgraded the Android to 4.4 but again no luck.
Did someone had this problem and how did you solved it?
P.S. The weird thing is that everything was working as expected initially: I was able to record about 2 minutes of screen recording with Telecine (few times). And then for no apparent reason it started to behave like this...
It turns out the reason is pretty simple: when Android Studio or Eclipse is running it obviously sends some adb messages periodically that interrupt the recording. The solution is stop the AS or eclipse and then to record.

What to do about curl clone.bundle error on AOSP repo sync

Upon downloading the master branch from AOSP I get the following error:
curl: (22) The requested URL returned error: 404 Not Found
Server does not provide clone.bundle; ignoring.
Why is this error coming?
Log:
* [new tag] android-cts-4.4_r1 -> android-cts-4.4_r1
* [new tag] android-sdk-4.4.2_r1 -> android-sdk-4.4.2_r1
Fetching projects: 7% (32/448) Fetching project platform/packages/apps/Launcher3
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 404 Not Found
Server does not provide clone.bundle; ignoring.
94 88.8M 94 83.9M 0 0 294k 0 0:05:08 0:04:51 0:00:17 357kremote: Sending approximately 108.84 MiB ...
remote: Counting objects: 9, done
remote: Finding sources: 100% (9/9)
94 88.8M 94 84.1M 0 0 294k 0 0:05:08 0:04:52 0:00:16 303kReceiving objects: 0% (1/44323)
Repo attempts to download a prepackaged bundle file to bootstrap each git prior to downloading the most recent data via Git's HTTP protocol. The latter is more expensive on the server side and results in worse performance so the bundle file allows the download to cut some corners. If a bundle file isn't available (like in this case), Repo will ignore it and proceed anyway. In other words, don't pay any attention to this.
In newer versions of repo, this can be ignored using the --no-clone-bundle option, such as:
repo sync --no-clone-bundle

Android RTSP - MediaPlayer init failure / PVMFFailure

I have a camera by Cisco and like to stream it's video stream to my android phone.
It's coded in MPEG4 so there should be no problem, but it's not working anymore (it worked with another camera a few weeks ago). Any idea what I might try ? I don't know what's wrong here.
I/ActivityManager( 79): Starting activity: Intent { cmp=com.Projekt1/.CameraView }
I/System.out(18792): SDPURL - rtsp://10.42.0.103:554/live.sdp
I/NotificationService( 79): enqueueToast pkg=com.Projekt1 callback=android.app.ITransientNotification$Stub$Proxy#44a22218 duration=0
D/MediaPlayer(18792): Couldn't open file on client side, trying server side
I/ActivityManager( 79): Displayed activity com.Projekt1/.CameraView: 270 ms (total 270 ms)
W/MediaPlayer(18792): info/warning (1, 26)
I/MediaPlayer(18792): Info (1,26)
E/PlayerDriver( 52): Command PLAYER_INIT completed with an error or info PVMFFailure
E/MediaPlayer(18792): error (1, -1)
E/MediaPlayer(18792): Error (1,-1)
D/VideoView(18792): Error: 1,-1
W/PlayerDriver( 52): PVMFInfoErrorHandlingComplete
Sorry Nils you have the right codec but Android supports only .3gp Streaming for video, i see you have
rtsp://10.42.0.103:554/live.sdp

Categories

Resources