Reputation: 2308
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
Upvotes: 2
Views: 13793
Reputation: 52353
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.
Upvotes: 6