I'd like to retrieve frames from video file.
My code followed the article Use Android Hardware Decoder with OMXCodec in NDK, and also referred the code of AwesomePlayer.cpp(AOSP) and libstagefright.cpp(ffmpeg). But it still hangs whenever OMXCodec start decoding. I have no idea what the problem is.
I'd grateful for any help.
the code:
int main(int argc, char *argv[])
{
OMXClient mClient;
status_t ret = mClient.connect();
LOGD("connect status is %d\n", ret);
sp<DataSource> mDs = DataSource::CreateFromURI("file:///sdcard/display/lwtwjod.mp4");
off64_t size = 0;
ret = mDs->getSize(&size);
LOGD("getSize[ret=%d]: %lld\n", ret, size);
sp<MediaExtractor> mMe = MediaExtractor::Create(mDs);
size_t tracksNum = mMe->countTracks();
LOGD("%u tracks\n", tracksNum);
sp<MediaSource> mMs;
bool hasVideo = false;
for(size_t i = 0; i != mMe->countTracks(); i++){
sp<MetaData> mMd_track = mMe->getTrackMetaData(i);
const char *_mime;
mMd_track->findCString(kKeyMIMEType, &_mime);
LOGD("the mime is %s\n", _mime);
String8 mime = String8(_mime);
if (!strncasecmp(mime.string(), "video/", 6)) {
LOGD("find video track!\n");
hasVideo = true;
mMs = mMe->getTrack(i);
int wid, hei;
mMd_track->findInt32(kKeyWidth, &wid);
mMd_track->findInt32(kKeyHeight, &hei);
LOGD("width: %d, height: %d\n", wid, hei);
break;
}
}
if(hasVideo){
sp<MediaSource> decoder =
OMXCodec::Create(mClient.interface(), mMs->getFormat(),
false, mMs,
NULL, OMXCodec::kClientNeedsFramebuffer);
LOGD("start decoding..\n");
ret = decoder->start(); // hangs here
LOGD("decoding return: %d\n", ret);
for(;;){
MediaBuffer *buffer;
buffer = NULL;
ret = decoder->read(&buffer);
LOGD("read decoded buffer result: %d\n", ret);
break;
}
}
}
The logcat output:
I/OMXClient( 5470): Using client-side OMX mux.
D/NativeCodec( 5470): connect status is 0
D/NativeCodec( 5470): getSize[ret=0]: 165748860
D/NativeCodec( 5470): 2 tracks
D/NativeCodec( 5470): the mime is video/avc
D/NativeCodec( 5470): find video track!
D/OMXCodec( 5470): Successfully allocated OMX node 'OMX.qcom.video.decoder.avc'
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] AVC profile = 100 (High), level = 31
E/OMX-VDEC-1080P( 197):
E/OMX-VDEC-1080P( 197): No color conversion required
E/OMX-VDEC-1080P( 197):
E/OMX-VDEC-1080P( 197): No color conversion required
E/OMX-VDEC-1080P( 197):
E/OMX-VDEC-1080P( 197): No color conversion required
E/OMX-VDEC-1080P( 197):
E/OMX-VDEC-1080P( 197): No color conversion required
E/OMX-VDEC-1080P( 197):
E/OMX-VDEC-1080P( 197): No color conversion required
E/OMX-VDEC-1080P( 197):
E/OMX-VDEC-1080P( 197): No color conversion required
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] video dimensions are 1280 x 720
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] Crop rect is 1280 x 720 # (0, 0)
D/NativeCodec( 5470): start decoding..
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocating 2 buffers of size 2097152 on input port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8e39390 on input port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8e393e0 on input port
E/OMX-VDEC-1080P( 197):
E/OMX-VDEC-1080P( 197): No color conversion required
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocating 15 buffers of size 1433600 on output port
E/OMX-VDEC-1080P( 197): GET_MV_BUFFER_SIZE returned: Size: 245760 and alignment: 8192
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9b08 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9b58 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9ba8 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9bf8 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9c48 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9c98 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9ce8 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9d38 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9d88 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9dd8 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9e28 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9e78 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9ec8 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9f18 on output port
I/OMXCodec( 5470): [OMX.qcom.video.decoder.avc] allocated buffer 0xb8eb9f68 on output port
E/OMXNodeInstance( 197): !!! Observer died. Quickly, do something, ... anything...
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9f68 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9f18 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9ec8 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9e78 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9e28 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9dd8 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9d88 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9d38 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9ce8 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9c98 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9c48 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9bf8 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9ba8 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9b58 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8eb9b08 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8e393e0 successful
I/OMXNodeInstance( 197): OMX_FreeBuffer for buffer header 0xb8e39390 successful
E/OMX-VDEC-1080P( 197):
E/OMX-VDEC-1080P( 197): Error in ioctl read next msg
E/ ( 197):
E/ ( 197): Destroy C2D instance
E/ ( 197):
E/ ( 197): Destroy C2D instance
Related
I had an Native Crash In FCNT Arrows F-41B device. When I play Ad,This is follow error Stack
# CodecLooper(12543)
SIGSEGV(SEGV_MAPERR)
#00 pc 000000000001f2b4 /system/lib64/libmedia_omx.so (android::hardware::media::omx::V1_0::utils::LWOmxNode::freeNode()+52) [arm64-v8a::d6ca6ad0aa6b451025aea9b50df3a511]
#01 pc 000000000009cdc8 /system/lib64/libstagefright.so (android::ACodec::LoadedState::onShutdown(bool)+128) [arm64-v8a::3a0f159449aafa5318775893fbfa1be5]
3
java:
4
[Failed to get Java stack]`
Log printing before errors:
`12312-29 23:18:37.554 900 6264 E ACodec : signalError(omxError 0x80001001, internalError -2)
12412-29 23:18:37.554 900 6264 E ACodec : [c2.android.avc.decoder] configureCodec returning error -2
12512-29 23:18:37.554 900 6264 E ACodec : signalError(omxError 0x80001001, internalError -2)
12612-29 23:18:37.554 900 6263 E MediaCodec: Codec reported err 0xfffffffe, actionCode 0, while in state 3/CONFIGURING
12712-29 23:18:37.555 900 6263 D SurfaceUtils: disconnecting from surface 0xb40000709bb72c70, reason disconnectFromSurface
12812-29 23:18:37.555 900 6263 E MediaCodec: Codec reported err 0xfffffffe, actionCode 0, while in state 0/UNINITIALIZED
12912-29 23:18:37.555 900 2389 E MediaCodec: configure failed with err 0xfffffffe, resetting...
130--------- beginning of crash
13112-29 23:18:37.600 6268 6264 F libc : fdsan: attempted to close file descriptor 293, expected to be unowned, actually owned by unique_fd 0x6f2bbf50d4
13212-29 23:18:38.647 6270 6270 E chromium: [1229/231838.646784:ERROR:process_memory_range.cc(75)] read out of range
13412-29 23:18:39.369 900 900 I Choreographer: Skipped 101 frames! The application may be doing too much work on its main thread.
13912-29 23:18:39.389 900 6264 E npth : Native crash was detected!
The videos are mp4. All other videos work fine, but weirdly, only certain videos come out this way.
I/ACodec (27533): codec does not support config priority (err -2147483648)
I was offered to change the audio codec while searching.
I tried encoding it with AAC, AC3, and MPEG but couldn't solve it. (I tried with each file)
It's really weird. The audio is a bit stuttering. It doesn't sound very annoying, but it certainly seems to be a bit cut off.
Does anyone know how to do this? Any advice would be appreciated. thank you.
I/ExoPlayerImpl( 8291): Init 6c53ea1 [ExoPlayerLib/2.12.1] [generic_x86_64, Android SDK built for x86_64, unknown, 24]
D/MetadataUtil( 8291): Skipped unknown metadata entry: ������
I/art ( 8291): Do partial code cache collection, code=25KB, data=24KB
I/art ( 8291): After code cache collection, code=23KB, data=23KB
I/art ( 8291): Increasing code cache capacity to 128KB
I/VideoCapabilities( 8291): Unsupported profile 4 for video/mp4v-es
I/OMXClient( 8291): MuxOMX ctor
I/MediaCodec( 8291): [OMX.google.h264.decoder] setting surface generation to 8489985
E/ACodec ( 8291): [OMX.google.h264.decoder] storeMetaDataInBuffers failed w/ err -1010
I/ACodec ( 8291): codec does not support config priority (err -2147483648)
I/ACodec ( 8291): codec does not support config operating rate (err -2147483648)
I/OMXClient( 8291): MuxOMX ctor
I/ACodec ( 8291): codec does not support config priority (err -2147483648)
D/AudioTrack( 8291): Client defaulted notificationFrames to 3675 for frameCount 11025
D/MediaCodec( 8291): [OMX.google.h264.decoder] setting dataspace on output surface to #104
D/ ( 8291): HostConnection::get() New Host Connection established 0x77a6caeb31c0, tid 8420
D/SoftwareRenderer( 8291): setting dataspace on output surface to #104
I/art ( 8291): Do partial code cache collection, code=61KB, data=59KB
I/art ( 8291): After code cache collection, code=58KB, data=57KB
I/art ( 8291): Increasing code cache capacity to 256KB
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)
I am trying to develop a surveillance application in OMAP 4460(Blaze Tablet-in ICS) acting as client device rendering the surveillance feed from a remote source. To begin with, surveillance feed is streamed remotely from the camera and port forwarded as RTP packets which are received and rendered in OMAP 4460 through a customized RTP stack. While rendering, I am getting the following error from the decoder, saying that "Surface Texture has been abandoned and native_window _set_buffers_geometry failed", more frequently.
Following is the log captured:
E/AwesomePlayer( 131): AwesomePlayer::onPrepareAsyncEvent-------- err = 0
E/AwesomePlayer( 131): AwesomePlayer::onPrepareAsyncEvent-------- OK = -430191887
I/OMXCodec( 131): [OMX.TI.DUCATI1.VIDEO.DECODER] AVC profile = 66 (Baseline), level = 31
E/OMXCodec( 131): set buffer size variable to : 307200
I/OMXCodec( 131): [OMX.TI.DUCATI1.VIDEO.DECODER] video dimensions are 640 x 480
I/OMXCodec( 131): [OMX.TI.DUCATI1.VIDEO.DECODER] Crop rect is 640 x 480 # (0, 0)
E/SurfaceTexture( 128): [SurfaceView] setCrop: SurfaceTexture has been abandoned!
E/SurfaceTextureClient( 131): ISurfaceTexture::setCrop(...) returned No such device
E/SurfaceTexture( 128): [SurfaceView] setLayout: SurfaceTexture has been abandoned!
E/SurfaceTexture( 128): [SurfaceView] setCrop: SurfaceTexture has been abandoned!
E/SurfaceTextureClient( 131): ISurfaceTexture::setCrop(...) returned No such device
E/OMXCodec( 131): native_window_set_buffers_geometry failed: No such device (19)
E/ion ( 131): ioctl -1073460991 failed with code -1: Bad file number
E/ion ( 131): ioctl -1073460991 failed with code -1: Bad file number
D/DOMX ( 131): hardware/ti/domx/domx/omx_proxy_common/src/omx_proxy_common.c:2208 PROXY_ComponentDeInit()
D/DOMX ( 131): ERROR: failed check:(eError == OMX_ErrorNone) || (eError == OMX_ErrorNoMore) - returning error: 0x80001011 - Error returned from OMX API in ducati
D/DOMX ( 131): hardware/ti/domx/omx_core/src/OMX_Core.c:396 OMX_FreeHandle()
D/DOMX ( 131): ERROR: Error From ComponentDeInit..
D/StackInterface( 131): AwesomePlayer::reset_l called ++
SDP of the camera:
v=0
o=StreamingServer 3331435948 1116907222000 IN IP4 192.168.1.102
s=h264.mp4
c=IN IP4 239.0.0.00;/1
t=0 0
a=control:*
m=video 0 RTP/AVP 96
a=control:trackID=0
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1; sprop-parameter-sets=Z0KAH9oCgPSbgIEAmBAAfQAAEZQve+Eg,aM48gA==
m=application 0 RTP/AVP 107
a=control:trackID=2
a=rtpmap:107 vnd.onvif.metadata/90000
I have been trying to fix this issue for sometime now, and could not able to find out the problem yet.
Kindly, reveal how to proceed further on the issue.
Regards,
Manoj
My English is not good.
Check SurfaceTexture pointer.
If you define sp<.....> in function, sp<.....> is abandoned with end of function.
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