Illegal Exception on MediaCodec.configure - android

I am trying to learn to encode a mp4 or any sort of video file using the Camera's onPreviewFrame call back.
Currently, I am trying the example codes from this post
Encoding H.264 from camera with Android MediaCodec
Unfortunately, I am keep getting an IllegalException on the
mediaCodec.configure(mediaFormat, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
From another post
IllegalStateException when MediaCodec.configure Android,
I notice that are some mandatory values I have to set for the MediaCodec.
I tried all the mandatory mediacodec's mandatory values but still no luck of getting past
the IllegalException.
Now I am kinda of running out of ideas to try. Any suggestions, opinions or hints would be greatly appreciated.
thanks
11-04 12:27:14.785 175-894/? E/mm-libcamera2﹕ PROFILE HAL: stopPreview(): E: 1383596834.803557773
11-04 12:27:14.795 175-175/? E/OMXNodeInstance﹕ !!! Observer died. Quickly, do something, ... anything...
11-04 12:27:14.795 208-5797/? E/mm-camera﹕ config_shutdown_pp Camera not in streaming mode. Returning.
11-04 12:27:14.795 208-5797/? E/mm-camera﹕ vfe_ops_deinit: E
11-04 12:27:14.825 175-5814/? E/OMX-VENC-720p﹕ ioctl VEN_IOCTL_CMD_READ_NEXT_MSG failed
11-04 12:27:14.825 175-175/? E/OMX-VENC-720p﹕ Destroy C2D instance
11-04 12:27:14.835 527-539/? E/qcom_sensors_hal﹕ hal_process_report_ind: Bad item quality: 11
11-04 12:28:17.642 6241-6247/? E/jdwp﹕ Failed sending reply to debugger: Broken pipe
11-04 12:28:17.912 527-539/? E/qcom_sensors_hal﹕ hal_process_report_ind: Bad item quality: 11
11-04 12:28:17.922 208-6264/? E/mm-camera﹕ sensor_load_chromatix: libchromatix_imx111_preview.so: 30
11-04 12:28:18.032 208-6264/? E/mm-camera﹕ vfe_ops_init: E
11-04 12:28:18.042 208-6264/? E/mm-camera﹕ vfe_legacy_stats_buffer_init: AEC_STATS_BUFNUM
11-04 12:28:18.052 208-6264/? E/mm-camera﹕ vfe_legacy_stats_buffer_init: AEC_STATS_BUFNUM
11-04 12:28:18.052 208-6264/? E/mm-camera﹕ mctl_init_stats_proc_info: snap_max_line_cnt =30096
11-04 12:28:18.213 6241-6241/? E/CamcorderProfile﹕ width: 720
11-04 12:28:18.213 6241-6241/? E/CamcorderProfile﹕ height: 480
11-04 12:28:18.213 6241-6241/? E/CamcorderProfile﹕ audioSampleRate: 48000
11-04 12:28:18.213 6241-6241/? E/CamcorderProfile﹕ videoBitRate: 5000000
11-04 12:28:18.213 6241-6241/? E/CamcorderProfile﹕ videoFrameRate: 30
11-04 12:28:18.233 175-617/? E/OMX-VENC-720p﹕ Is component secure 0
11-04 12:28:18.263 6241-6280/? E/ACodec﹕ [OMX.qcom.video.encoder.avc] does not support color format 19
11-04 12:28:18.263 6241-6280/? E/ACodec﹕ [OMX.qcom.video.encoder.avc] configureCodec returning error -2147483648
11-04 12:28:18.263 6241-6279/? E/MediaCodec﹕ Codec reported an error. (omx error 0x80001001, internalError -2147483648)
11-04 12:28:18.263 6241-6241/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalStateException
at android.media.MediaCodec.native_configure(Native Method)
at android.media.MediaCodec.configure(MediaCodec.java:259)
at com.example.mediacodec.AvcEncoder.<init>(AvcEncoder.java:40)
at com.example.mediacodec.Preview.surfaceCreated(MediaCodecActivity.java:304)
at android.view.SurfaceView.updateWindow(SurfaceView.java:571)
at android.view.SurfaceView.access$000(SurfaceView.java:86)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:175)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:833)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1860)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
at android.view.Choreographer.doCallbacks(Choreographer.java:562)
at android.view.Choreographer.doFrame(Choreographer.java:532)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
11-04 12:28:20.135 175-617/? E/mm-libcamera2﹕ PROFILE HAL: stopPreview(): E: 1383596900.149872429
11-04 12:28:20.135 175-575/? E/OMXNodeInstance﹕ !!! Observer died. Quickly, do something, ... anything...
11-04 12:28:20.135 208-6264/? E/mm-camera﹕ config_shutdown_pp Camera not in streaming mode. Returning.
11-04 12:28:20.145 208-6264/? E/mm-camera﹕ vfe_ops_deinit: E
11-04 12:28:20.165 175-6283/? E/OMX-VENC-720p﹕ ioctl VEN_IOCTL_CMD_READ_NEXT_MSG failed
11-04 12:28:20.165 175-575/? E/OMX-VENC-720p﹕ Destroy C2D instance
11-04 12:28:20.195 527-539/? E/qcom_sensors_hal﹕ hal_process_report_ind: Bad item quality: 11

E/ACodec﹕ [OMX.qcom.video.encoder.avc] does not support color format 19
Looks like you're trying to use color format 19 (COLOR_FormatYUV420Planar, a/k/a I420) on a Qualcomm device. A quick test on one of my devices indicates their codecs want color format 21 (COLOR_FormatYUV420SemiPlanar, a/k/a NV12).
The buffer-to-buffer tests in the EncodeDecodeTest sources show how to query the MediaCodecInfo for an appropriate color format. Since you are receiving input from the Camera, you will want to set the preview format to a semi-planar layout (NV21), and then do the U/V swap before handing it to the MediaCodec.
If you have Android 4.3 or later, you can skip all of the format gymnastics and use the Surface preview output. See the CameraToMpegTest sources for an example.

Related

Firebase for unity crashes

After updating my game, Firebase crashes. I upgrade first to the last version 5.4.0 but still got the same error. I downgrade to 5.2.0 but nothing change. On my console, using adb logcat, I have :
11-04 01:37:37.420 1318 1333 W HwPolicyFactoryImpl: mAware is disable
11-04 01:37:37.462 12161 12308 E Unity : DllNotFoundException: FirebaseCppApp-5.2.0
11-04 01:37:37.462 12161 12308 E Unity : at (wrapper managed-to-native) Firebase.AppUtilPINVOKE/SWIGExceptionHelper:SWIGRegisterExceptionCallbacks_AppUtil (Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate,Firebase.AppUtilPINVOKE/SWIGExceptionHelper/ExceptionDelegate)
11-04 01:37:37.462 12161 12308 E Unity : at Firebase.AppUtilPINVOKE+SWIGExceptionHelper..cctor () [0x00000] in <filename unknown>:0
11-04 01:37:37.462 12161 12308 E Unity : Rethrow as TypeInitializationException: An exception was thrown by the type initialize
11-04 01:37:37.792 1318 1478 E WifiConfigManager: updateConfiguration freq=2467 BSSID=14:0c:**:**:fa:dc RSSI=-66 "TuNeTeConnecterasPas"WPA_PSK
11-04 01:37:38.188 1318 1542 E HwCHRWifiRSSIGroupSummery: updatArpSummery mRSSI:-66 HwCHRWifiRSSIGroup [rssi_index=3, rtt_tcp_packets=824, rtt_tcp_duration=58535, rtt_lan_duration=3215, rtt_lan_failures=0, rtt_lan_succ=161, rtt_lan_max=73, rtt_lan_min=4,same_area_frequency=0,adjacent_area_frequency=0]
11-04 01:37:38.401 1318 1318 I TrafficMonitor: expired arrive. level:-1
11-04 01:37:38.401 1318 1318 I TrafficMonitor: during_ms:2001,period_ms:2000
Please could you know how could I correct it ?
I use unity 2018, jdk8, target android 27.

Android Web View Crash

My app was working fine. I had to format my computer and phone. Now the keep app crashing. I'm using a web view to display youtube everything works fine until I try to switch to full screen then I get the errors. I don't know how to solve with this problem.
08-10 21:41:27.005 31363-31363/? E/Zygote﹕ MountEmulatedStorage()
08-10 21:41:27.005 31363-31363/? E/Zygote﹕ v2
08-10 21:41:27.045 31363-31363/? E/SELinux﹕ [DEBUG] get_category: variable seinfo: default sensitivity: NULL, cateogry: NULL
08-10 21:41:36.865 31363-31959/com.videowebviewtest.unknown.webview_video_test E/ACodec﹕ onConfigureComponent mime.c_str() = audio/mp4a-latm
08-10 21:41:36.915 31363-31977/com.videowebviewtest.unknown.webview_video_test E/ACodec﹕ onConfigureComponent mime.c_str() = video/x-vnd.on2.vp9
08-10 21:41:36.915 31363-31977/com.videowebviewtest.unknown.webview_video_test E/ACodec﹕ [OMX.google.vp9.decoder] storeMetaDataInBuffers failed w/ err -2147483648
08-10 21:41:45.915 31363-31363/com.videowebviewtest.unknown.webview_video_test A/chromium﹕ [FATAL:jni_android.cc(271)] Check failed: false.
08-10 21:41:45.915 31363-31363/com.videowebviewtest.unknown.webview_video_test A/libc﹕ Fatal signal 6 (SIGABRT), code -6 in tid 31363 (view_video_test)

How to set the Android MediaCodec profile?

I am try to set the profile, such as:
MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline
The code snippet like this:
MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, config.getWidth(), config.getHeight());
format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
format.setInteger(MediaFormat.KEY_BIT_RATE, config.getBitrate());
format.setInteger(MediaFormat.KEY_FRAME_RATE, config.getHumanFPS());
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, config.getIFrameInterval());
format.setInteger(MediaFormat.KEY_PROFILE, MediaCodecInfo.CodecProfileLevel.AVCProfileBaseline);
mEncoder = MediaCodec.createEncoderByType(MIME_TYPE);
mEncoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
But I got the following error:
07-24 08:05:54.981 I/OMX-VENC( 298): Component_init : OMX.qcom.video.encoder.avc : return = 0x0
07-24 08:05:54.989 E/OMX-VENC( 298): set_parameter: metamode is valid for input port only
07-24 08:05:54.989 E/OMXNodeInstance( 298): OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x8000101a
07-24 08:05:54.992 E/ACodec ( 8612): [OMX.qcom.video.encoder.avc] storeMetaDataInBuffers (output) failed w/ err -2147483648
07-24 08:05:54.994 W/ACodec ( 8612): do not know color format 0x7fa30c04 = 2141391876
07-24 08:05:54.994 W/ACodec ( 8612): do not know color format 0x7f000789 = 2130708361
07-24 08:05:54.997 D/FFmpegMuxer( 8612): RECEIVED AUDIO DATA NOT ALL TRACKS ADDED
07-24 08:05:55.005 I/art ( 810): Explicit concurrent mark sweep GC freed 21609(1113KB) AllocSpace objects, 2(32KB) LOS objects, 39% free, 18MB/30MB, paused 2.045ms total 137.471ms
07-24 08:05:55.012 I/ACodec ( 8612): [OMX.qcom.video.encoder.avc] setupVideoEncoder failed
07-24 08:05:55.012 E/ACodec ( 8612): [OMX.qcom.video.encoder.avc] configureCodec returning error -38
07-24 08:05:55.012 E/ACodec ( 8612): signalError(omxError 0x80001001, internalError -2147483648)
07-24 08:05:55.013 E/MediaCodec( 8612): Codec reported err 0x80001001, actionCode 0, while in state 3
07-24 08:05:55.013 E/MediaCodec( 8612): configure failed with err 0x80001001, resetting...
07-24 08:05:55.014 I/OMX-VENC( 298): Component Deinit
07-24 08:05:55.016 I/OMXClient( 8612): Using client-side OMX mux.
07-24 08:05:55.023 I/OMX-VENC( 298): Component_init : OMX.qcom.video.encoder.avc : return = 0x0
--------- beginning of crash
07-24 08:05:55.028 E/AndroidRuntime( 8612): FATAL EXCEPTION: TextureMovieEncoder
07-24 08:05:55.028 E/AndroidRuntime( 8612): Process: com.camera.demo, PID: 8612
07-24 08:05:55.028 E/AndroidRuntime( 8612): android.media.MediaCodec$CodecException: Error 0x80001001
07-24 08:05:55.028 E/AndroidRuntime( 8612): at android.media.MediaCodec.native_configure(Native Method)
07-24 08:05:55.028 E/AndroidRuntime( 8612): at android.media.MediaCodec.configure(MediaCodec.java:577)
Where did i miss?
If you set the profile, you may need to set the level as well - have a look at setupAVCEncoderParameters in https://android.googlesource.com/platform/frameworks/av/+/6ade04174/media/libstagefright/ACodec.cpp. See https://stackoverflow.com/a/26293422/3115956 for a similar answer and an explanation on how to pick a value to set as level.

How to properly handle RejectedExecutionException for AsyncTasks?

I currently have a BaseAdapter that is populating a gallery of thumbnails. When an item is visible, an AsyncTask is started from the adapters getView() method to download the thumbnail and when completed the imageview is updated with the correct bitmap. This seems to work really well, except when the user scrolls really fast. This is because of the AsyncTask limitations of holding 128 threads in the queue at any given time.
So my question is how do I properly detect whether the thread pool is full before scheduling another task? Or how do I properly catch the error so I don't receive a force close?
Here are the errors I'm receiving:
5-06 10:54:11.416 27931-27931/com.diverg.tidy E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.diverg.tidy, PID: 27931
java.util.concurrent.RejectedExecutionException: Task android.os.AsyncTask$3#426c4e80 rejected from java.util.concurrent.ThreadPoolExecutor#41bddce0[Running, pool size = 5, active threads = 5, queued tasks = 128, completed tasks = 35]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2011)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:793)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1339)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:590)
at com.diverg.tidy.MediaAdapter.getView(MediaAdapter.java:90)
at android.widget.AbsListView.obtainView(AbsListView.java:2263)
at android.widget.GridView.makeAndAddView(GridView.java:1345)
at android.widget.GridView.makeRow(GridView.java:345)
at android.widget.GridView.fillDown(GridView.java:287)
at android.widget.GridView.fillFromTop(GridView.java:421)
at android.widget.GridView.layoutChildren(GridView.java:1233)
at android.widget.AbsListView.onLayout(AbsListView.java:2091)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1660)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1436)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at android.view.View.layout(View.java:14817)
at android.view.ViewGroup.layout(ViewGroup.java:4631)
at android.widget.ListView.setupChild(ListView.java:1882)
at android.widget.ListView.makeAndAddView(ListView.java:1793)
at android.widget.ListView.fillDown(ListView.java:691)
at android.widget.ListView.fillGap(ListView.java:655)
at android.widget.AbsListView.trackMotionScroll(AbsListView.java:5136)
at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:4247)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:543)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
05-06 10:54:13.299 29540-29540/? E/dalvikvm﹕ /system/priv-app/GooglePartnerSetup.apk odex has stale dependencies
05-06 10:54:19.346 8024-8024/? E/fb4a(:<default>):AddressResolver﹕ Failed to deserialize to instance com.facebook.mqtt.AddressEntry
at [Source: java.io.StringReader#42180f18; line: 1, column: 34]
05-06 10:54:20.018 125-439/? E/Netd﹕ Failed to write /sys/class/net/rmnet1/mtu: Invalid argument
05-06 10:54:20.025 447-522/? E/ConnectivityService﹕ exception in setMtu()java.lang.IllegalStateException: command '5905 interface setmtu rmnet1 1500' failed with '400 5905 Failed to get MTU (Invalid argument)'
05-06 10:54:20.369 447-1037/? E/ConnectivityService﹕ startUsingNetworkFeature took too long: 330ms
05-06 10:54:20.393 125-439/? E/Netd﹕ Failed to write /sys/class/net/rmnet1/mtu: Invalid argument
05-06 10:54:20.393 447-522/? E/ConnectivityService﹕ exception in setMtu()java.lang.IllegalStateException: command '5917 interface setmtu rmnet1 1500' failed with '400 5917 Failed to get MTU (Invalid argument)'
05-06 10:54:21.439 447-503/? E/WifiStateMachine﹕ Unexpected BatchedScanResults :OK
05-06 10:54:22.096 447-522/? E/ConnectivityService﹕ Unexpected mtu value: android.net.wifi.WifiStateTracker#423a09c0
05-06 10:54:23.932 29936-29936/? E/dalvikvm﹕ /system/priv-app/SetupWizard.apk odex has stale dependencies
05-06 10:54:24.127 29936-29936/? E/PhoneMonitor﹕ onOtaspChanged old =0, new =3
05-06 10:54:24.338 29957-29957/? E/dalvikvm﹕ /system/app/GalleryGoogle.apk odex has stale dependencies
05-06 10:54:25.127 125-439/? E/SecondaryTablController﹕ ip route del failed: /system/bin/ip route del 10.182.14.1/32 via 0.0.0.0 dev rmnet1 table 60
05-06 10:54:25.143 125-439/? E/SecondaryTablController﹕ ip route del failed: /system/bin/ip route del 0.0.0.0/0 via 10.182.14.1 dev rmnet1 table 60
05-06 10:54:25.150 125-439/? E/SecondaryTablController﹕ ip route del failed: /system/bin/ip route del 2600:1014:b10b:6554::1/128 via :: dev rmnet1 table 60
05-06 10:54:25.166 125-439/? E/SecondaryTablController﹕ ip route del failed: /system/bin/ip route del ::/0 via 2600:1014:b10b:6554::1 dev rmnet1 table 60
You can go through documentation of AsyncTask:
http://developer.android.com/reference/android/os/AsyncTask.html
And you can use getStatus() of AsyncTask to know the status of the worker thread. See http://developer.android.com/reference/android/os/AsyncTask.html#getStatus%28%29
I ended up using this as a template. It works by creating a worker thread and adding images to it's queue.

Failed to instantiate mediaextractor when using setDataSource()

I am trying to extract Track 0 (video track) of an avi file using MediaExtract and encode to h264 format using MediaCodec. Here is how i configured mediaCodec
public MediaCodec configure_codec(){
Log.d("OUT","configure starts");
MediaCodec codec = MediaCodec.createEncoderByType("video/avc");
MediaFormat format = MediaFormat.createVideoFormat("video/avc", 320, 240);
format.setInteger(MediaFormat.KEY_BIT_RATE, 700000);
format.setInteger(MediaFormat.KEY_FRAME_RATE, 15);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT,MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 5);
//Configure codec for encoding
codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
Log.d("OUT","codec configured");
return codec;
}
The problem i am facing is in this part.
public MediaExtractor extract_video()
{
MediaExtractor extractor = new MediaExtractor();
//problem in this line
try{
extractor.setDataSource(file_in);
}catch(Throwable th){
Log.d("OUT", th.getMessage());
}
MediaFormat format = extractor.getTrackFormat(0);
String mime = format.getString(MediaFormat.KEY_MIME);
Log.d("OUT", String.format("MIME TYPE: %s", mime));
extractor.selectTrack(0);
return extractor;
}
Here is the log.
07-01 10:53:53.284: D/OUT(1779): Main starts
07-01 10:53:54.024: I/Choreographer(1779): Skipped 82 frames! The application may be doing too much work on its main thread.
07-01 10:53:54.373: I/Choreographer(1779): Skipped 247 frames! The application may be doing too much work on its main thread.
07-01 10:53:54.433: D/gralloc_goldfish(1779): Emulator without GPU emulation detected.
07-01 10:54:00.194: I/Choreographer(1779): Skipped 36 frames! The application may be doing too much work on its main thread.
07-01 10:54:00.336: D/OUT(1779): Button Start
07-01 10:54:00.336: D/OUT(1779): start starts
07-01 10:54:00.344: D/OUT(1779): /mnt/sdcard/test.avi
07-01 10:54:00.344: D/OUT(1779): /mnt/sdcard/result.h264
07-01 10:54:00.344: D/OUT(1779): configure starts
07-01 10:54:00.394: I/OMXClient(1779): Using client-side OMX mux.
07-01 10:54:00.504: I/SoftAVCEncoder(1779): Construct SoftAVCEncoder
07-01 10:54:00.534: I/ACodec(1779): setupVideoEncoder succeeded
07-01 10:54:00.534: E/OMXNodeInstance(1779): OMX_GetExtensionIndex failed
07-01 10:54:00.544: D/OUT(1779): codec configured
07-01 10:54:00.734: E/WVMExtractor(1779): Failed to open libwvm.so
07-01 10:54:00.734: D/OUT(1779): Failed to instantiate extractor.
07-01 10:54:00.744: D/AndroidRuntime(1779): Shutting down VM
07-01 10:54:00.755: W/dalvikvm(1779): threadid=1: thread exiting with uncaught exception (group=0x40a13300)
07-01 10:54:00.924: E/AndroidRuntime(1779): FATAL EXCEPTION: main
07-01 10:54:00.924: E/AndroidRuntime(1779): java.lang.IllegalArgumentException
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.media.MediaExtractor.getTrackFormatNative(Native Method)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.media.MediaExtractor.getTrackFormat(MediaExtractor.java:195)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.app.convert_final.encoder_pack.extract_video(encoder_pack.java:46)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.app.convert_final.encoder_pack.start(encoder_pack.java:81)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.app.convert_final.MainActivity$1.onClick(MainActivity.java:27)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.view.View.performClick(View.java:4084)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.view.View$PerformClick.run(View.java:16966)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.os.Handler.handleCallback(Handler.java:615)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.os.Handler.dispatchMessage(Handler.java:92)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.os.Looper.loop(Looper.java:137)
07-01 10:54:00.924: E/AndroidRuntime(1779): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-01 10:54:00.924: E/AndroidRuntime(1779): at java.lang.reflect.Method.invokeNative(Native Method)
07-01 10:54:00.924: E/AndroidRuntime(1779): at java.lang.reflect.Method.invoke(Method.java:511)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-01 10:54:00.924: E/AndroidRuntime(1779): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-01 10:54:00.924: E/AndroidRuntime(1779): at dalvik.system.NativeStart.main(Native Method)
07-01 10:54:03.394: I/Process(1779): Sending signal. PID: 1779 SIG: 9
How should i solve this issue?
What is libwvm.so? Why does it fail to open?
Here is how i called the functions:
public void start()
{
this.running = true;
Log.d("OUT","start starts");
Log.d("OUT", file_in);
Log.d("OUT", file_out);
codec = configure_codec();
extractor = extract_video();
now_start();
}
MediaInfo of "test.avi"
General
Complete name : D:\test.avi
Format : AVI
Format/Info : Audio Video Interleave
File size : 967 KiB
Duration : 2s 500ms
Overall bit rate : 3 169 Kbps
Video
ID : 0
Format : JPEG
Codec ID : MJPG
Duration : 2s 500ms
Bit rate : 2 782 Kbps
Width : 320 pixels
Height : 240 pixels
Original height : 480 pixels
Display aspect ratio : 4:3
Frame rate : 30.000 fps
Color space : YUV
Chroma subsampling : 4:2:2
Bit depth : 8 bits
Scan type : Interlaced
Compression mode : Lossy
Bits/(Pixel*Frame) : 1.207
Stream size : 849 KiB (88%)
Audio
ID : 1
Format : PCM
Format settings, Endianness : Little
Format settings, Sign : Signed
Codec ID : 1
Duration : 2s 500ms
Bit rate mode : Constant
Bit rate : 352.8 Kbps
Channel(s) : 1 channel
Sampling rate : 22.05 KHz
Bit depth : 16 bits
Stream size : 108 KiB (11%)
Alignment : Aligned on interleaves
Interleave, duration : 33 ms (1.00 video frame)
Full code here: http://pastebin.com/WiCp4SPq encoder_pack.java
http://pastebin.com/JjyR9pdH Main_Activity.java
I asked this myself (I had too much information to add it as a comment here) MediaExtractor.setDataSource throws IOException "failed to instantiate extractor" and I think I've answered my own question now.
It would appear that if, instead of asking it to extract from a file, I open the file myself, get an input stream, get the FileDescriptor from the input stream, and then ask it to extract from the file descriptor, it works every time.
Can device play this file with some built-in player(ie pre-installed)?
I never saw devices writing "*.avi" file with native camera, so I suspect that MediaCodec implementation on the device just does not support this file format.

Categories

Resources