use android mediacodec encode aac on galaxy s4 4.3 - android

I use MediaCodec to encode aac stream and then mux to mp4, I test on most devices works properly , but on Galaxy S4 with 4.3, API level 18, the problem cames, below is the code:
if (mHasAudioTrack) {
mAudioCodec = MediaCodec.createEncoderByType("audio/mp4a-latm");
MediaFormat audioFormat = MediaFormat.createAudioFormat("audio/mp4a-latm", 44100, 2);
audioFormat.setInteger(MediaFormat.KEY_AAC_PROFILE, MediaCodecInfo.CodecProfileLevel.AACObjectLC);
audioFormat.setInteger(MediaFormat.KEY_CHANNEL_MASK, AudioFormat.CHANNEL_IN_STEREO);
audioFormat.setInteger(MediaFormat.KEY_CHANNEL_COUNT, 2);
audioFormat.setInteger(MediaFormat.KEY_BIT_RATE, 128000);
try {
mAudioCodec.configure(audioFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
} catch (Exception e) {
Log.e(logTag, "configure audio codec err:"+e.getMessage()+"use no audio");
mHasAudioTrack = false;
mAudioCodec.release();
}
}
and the error log is:
> 11-16 11:40:51.006 20858-21098/com.youku.demorecord
> E/TDScreenVideoWriter﹕ Create media codec context. 11-16 11:40:51.126
> 20858-21594/com.youku.demorecord W/ACodec﹕ [OMX.google.aac.decoder]
> Failed to set standard component role 'audio_encoder.aac'. 11-16
> 11:40:51.126 20858-21594/com.youku.demorecord E/ACodec﹕
> [OMX.google.aac.decoder] configureCodec returning error -2147483648
> 11-16 11:40:51.126 20858-21594/com.youku.demorecord E/MediaCodec﹕
> Codec reported an error. (omx error 0x80001001, internalError
> -2147483648) 11-16 11:40:51.126 20858-21098/com.youku.demorecord E/TDScreenVideoWriter﹕ configure audio codec err:nulluse no audio
Any parameters is wrong?
Is there any guys face same problem and can give me some tips? thanks very much.
btw:I don't want to compile third aac encoder library use ndk.

Related

android webrtc crash Unable to instantiate codec 'OMX.qcom.video.decoder.vp8' with err 0xfffffff4

im using webrtc for calling, but it's crash in China rom device mostly but also some others(even samsung). here is the crash log:
2021-09-12 18:29:31.899 1218-14625/? E/OMX-VDEC-1080P: Omx_vdec::Comp Init Returning failure, errno 12
2021-09-12 18:29:31.899 1218-14625/? E/OMX-VDEC-1080P: eventfd_write failed for fd: -1, errno = 9, force stop async_thread
2021-09-12 18:29:31.899 1218-14625/? E/OMX-VDEC-1080P: Invalid input: -1
2021-09-12 18:29:31.913 1218-14625/? E/android.hardware.media.omx#1.0-service: Failed to allocate omx component 'OMX.qcom.video.decoder.vp8' err=InsufficientResources(0x80001000)
2021-09-12 18:29:31.916 3298-27657/com.civix.link E/ACodec: Unable to instantiate codec 'OMX.qcom.video.decoder.vp8' with err 0xfffffff4.
2021-09-12 18:29:31.916 3298-27657/com.civix.link E/ACodec: signalError(omxError 0xfffffff4, internalError -12)
2021-09-12 18:29:31.918 3298-27656/com.civix.link E/MediaCodec: Codec reported err 0xfffffff4, actionCode 0, while in state 1
2021-09-12 18:29:31.924 1195-32507/? E/ResourceManagerService: getLowestPriorityBiggestClient_l: lowest priority 0 vs caller priority 0
2021-09-12 18:29:31.925 3298-25911/com.civix.link W/MediaCodec-JNI: try to release MediaCodec from JMediaCodec::~JMediaCodec()...
2021-09-12 18:29:31.925 3298-25911/com.civix.link W/MediaCodec-JNI: done releasing MediaCodec from JMediaCodec::~JMediaCodec().
2021-09-12 18:29:31.925 3298-25911/com.civix.link W/System.err: android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.vp8, error 0xfffffff4
2021-09-12 18:29:31.925 3298-25911/com.civix.link W/System.err: at android.media.MediaCodec.native_setup(Native Method)
2021-09-12 18:29:31.925 3298-25911/com.civix.link W/System.err: at android.media.MediaCodec.<init>(MediaCodec.java:1912)
2021-09-12 18:29:31.925 3298-25911/com.civix.link W/System.err: at android.media.MediaCodec.createByCodecName(MediaCodec.java:1890)
2021-09-12 18:29:31.925 3298-25911/com.civix.link W/System.err: at org.webrtc.HardwareVideoDecoder.initDecodeInternal(HardwareVideoDecoder.java:173)
2021-09-12 18:29:31.925 3298-25911/com.civix.link W/System.err: at org.webrtc.HardwareVideoDecoder.initDecode(HardwareVideoDecoder.java:150)
2021-09-12 18:29:31.925 3298-25911/com.civix.link E/rtc: #
# Fatal error in: gen/sdk/android/generated_base_jni/jni/../../../../../../../../../usr/local/google/home/sakal/code/webrtc-aar-release/src/sdk/android/src/jni/jni_generator_helper.h, line 37
# last system error: 0
# Check failed: !env->ExceptionCheck()
#
I have some device work normally, but in some device(even Samsung) it crash after 1 minute -> 30 minutes running call.
About my webrtc, im using default all:
peerConnectionFactory = PeerConnectionFactory.builder()
.setOptions(options)
.setVideoEncoderFactory(new DefaultVideoEncoderFactory(MeetingClient.mRootEglBase.getEglBaseContext(), true, true))
.setVideoDecoderFactory(new DefaultVideoDecoderFactory(MeetingClient.mRootEglBase.getEglBaseContext()))
.createPeerConnectionFactory();
Can someone tech me how to solve this? Thanks

ExoPlayerImplInternal: Stop failed. java.lang.IllegalStateException - on API Level 22 and below

I have a problem with HLS streams on devices Android 22 Api and below for cameras with high definition 2688x1520 and bitrate 5812 - stream can't play. I use ExoPlayer version 2.9.6 (also testing with 2.10.4). On other devices and other cameras - all ok. Please help me to resolve this issue.
Short logs:
D: NoSupport [codec.profileLevel, avc1.4D4032, video/avc] [OMX.google.h264.decoder, video/avc] [generic_x86_64, Android SDK built for x86_64, unknown, 22]
I: Using client-side OMX mux.
E: [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -1010
E: [OMX.google.h264.decoder] ERROR(0x80001001)
E: signalError(omxError 0x80001001, internalError -2147483648)
E: Codec reported err 0x80001001, actionCode 0, while in state 6
E: Internal runtime error.
java.lang.IllegalStateException
at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:1033)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.drainOutputBuffer(MediaCodecRenderer.java:1287)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:663)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:536)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:303)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
E: Stop failed.
java.lang.IllegalStateException
at android.media.MediaCodec.native_stop(Native Method)
at android.media.MediaCodec.stop(MediaCodec.java:628)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.releaseCodec(MediaCodecRenderer.java:608)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.releaseCodec(MediaCodecVideoRenderer.java:508)
at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onDisabled(MediaCodecRenderer.java:562)
at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onDisabled(MediaCodecVideoRenderer.java:377)
at com.google.android.exoplayer2.BaseRenderer.disable(BaseRenderer.java:153)
at com.google.android.exoplayer2.ExoPlayerImplInternal.disableRenderer(ExoPlayerImplInternal.java:983)
at com.google.android.exoplayer2.ExoPlayerImplInternal.resetInternal(ExoPlayerImplInternal.java:771)
at com.google.android.exoplayer2.ExoPlayerImplInternal.stopInternal(ExoPlayerImplInternal.java:742)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:358)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
D: java.lang.IllegalStateException
Link issue on github with full bug report
https://github.com/google/ExoPlayer/issues/6433
NoSupport [codec.profileLevel, avc1.4D4032, video/avc]
Your video uses H.264 Main Profile (avc1.4D) which is not supported by these particular devices. The minimum requirement for Main Profile is 6.0+. You could check if there's another software decoder available (see MediaCodecSelector), although ExoPlayer will pick the best one.

ACodec configureCodec returning error -38

I am trying to configure a video encoder using MediaCodec for mime=video/avc, width=1920, height=1080.
Unfortunately the device complains with the following log:
12-20 13:11:49.410 5781-5817/ I/OMXClient: Treble IOmx obtained
12-20 13:11:49.423 5781-5817/ E/ACodec: [OMX.google.h264.encoder] configureCodec returning error -38
12-20 13:11:49.424 5781-5817/ E/ACodec: signalError(omxError 0x80001001, internalError -2147483648)
12-20 13:11:49.424 5781-5816/ E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 3
12-20 13:11:49.425 5781-5801/ E/MediaCodec: configure failed with err 0x80001001, resetting...
12-20 13:11:49.433 5781-5817/com.humaneyes.filesave I/OMXClient: Treble IOmx obtained
Some codecs are finicky and require special properties.
Failing to specify some of these can cause the MediaCodec configure()
call to throw an unhelpful exception.
Must define the following integer properties in the MediaFormat at a minimum:
MediaFormat.KEY_BIT_RATE
MediaFormat.KEY_FRAME_RATE
MediaFormat.KEY_I_FRAME_INTERVAL
MediaFormat.KEY_COLOR_FORMAT
For example:
MediaFormat mediaFormat = MediaFormat.createVideoFormat("video/avc", 1920, 1080);
mediaFormat.setInteger(MediaFormat.KEY_BIT_RATE, 2000000);
mediaFormat.setInteger(MediaFormat.KEY_FRAME_RATE, 30);
mediaFormat.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
mediaFormat.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 1);

Media Codec : Insufficient sized buffer

When i play video with resolution 704x576 (using MediaCodec) . I'm seeing this error and app is crashing
Logs:
12-04 04:35:55.507 E/OMX-VDEC-1080P( 9621): Insufficient sized buffer given for playback, expected 2514944, got 2506752
12-04 04:35:55.507 E/OMXNodeInstance( 9621): OMX_UseBuffer failed with error -2147479547 (0x80001005)
12-04 04:35:55.507 E/ACodec (22699): registering GraphicBuffer 0 with OMX IL component failed: -2147483648
12-04 04:35:55.507 E/ACodec (22699): Failed to allocate output port buffers after port reconfiguration (error 0x80000000)
12-04 04:35:55.507 E/MediaCodec(22699): Codec reported an error. (omx error 0x80001001, internalError -2147483648)

ts file not playing in android tablet

I am trying to play a file i have recorded. The file plays well in vlc(linux pc) and in Moboplayer(android tablet). While using the default player in the android tablet it shows this in logcat.
I/ActivityManager( 201): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.example.mymediaplayer/.MyVideoView bnds=[656,246][752,342]} from pid 417
I/System.out(20286): MyVideoView.onCreate()
I/System.out(20286): MyVideoView.onResume()
V/TabletStatusBar( 281): setLightsOn(true)
I/AwesomePlayer( 141): setDataSource_l('/sdcard/video/TunerOut.ts')
I/avc_utils( 141): found AVC codec config (720 x 480, Baseline-profile level 3.1)
I/MPEG2TSExtractor( 141): haveAudio=1, haveVideo=1
E/OMXCodec( 141): Attempting to allocate OMX node 'OMX.TI.DUCATI1.VIDEO.DECODER'
E/OMXCodec( 141): Attempting to allocate OMX node 'OMX.Nvidia.h264.decode'
E/OMXCodec( 141): Attempting to allocate OMX node 'OMX.qcom.7x30.video.decoder.avc'
E/OMXCodec( 141): Attempting to allocate OMX node 'OMX.qcom.video.decoder.avc'
E/OMXCodec( 141): Attempting to allocate OMX node 'OMX.TI.Video.Decoder'
E/OMXCodec( 141): Attempting to allocate OMX node 'OMX.SEC.AVC.Decoder'
E/OMXCodec( 141): Successfully allocated OMX node 'OMX.SEC.AVC.Decoder'
I/OMXCodec( 141): [OMX.SEC.AVC.Decoder] AVC profile = 66 (Baseline), level = 31
E/OMXCodec( 141): [OMX.SEC.AVC.Decoder] Video O/P format.eColorFormat 0x40b452b1
I/OMXCodec( 141): [OMX.SEC.AVC.Decoder] video dimensions are 720 x 480
D/OpenGLRenderer( 417): Flushing caches (mode 1)
I/ActivityManager( 201): Displayed com.example.mymediaplayer/.MyVideoView: +323ms
W/InputManagerService( 201): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy#4106dc38 (uid=10036 pid=20503)
W/IInputConnectionWrapper(20503): showStatusIcon on inactive InputConnection
E/OMXCodec( 141): Attempting to allocate OMX node 'OMX.Nvidia.mp2.decoder'
**E/MediaPlayer(20286): error (1, -2147483648)
E/MediaPlayer(20286): Error (1,-2147483648)
D/VideoView(20286): Error: 1,-2147483648**
D/OpenGLRenderer( 417): Flushing caches (mode 0)
W/InputManagerService( 201): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#41033300
D/AudioHardware( 141): AudioHardware pcm playback is going to standby.
what is error 1,-2147483648
I just had that error too. The reason (in my case) was that the mp3 has the wrong format, i.e.
MPEG ADTS, layer II, v1, 192 kbps, 44.1 kHz, Stereo
while a "good" mp3 has this format:
MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JntStereo

Categories

Resources