Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: MPEG4Writer fails to start when using OMXCodec as MediaSource
    primarykey
    data
    text
    <p> I'm trying to encode a video from a byte array buffer and to do so I'm using <code>MPEG4Writer</code> API from native code.</p> <p>I have created my custom <code>MediaSource</code> class to provide the data and I'm wrapping it with <code>OMXCodec</code> to give it to <code>MPEG4Writer</code>:</p> <pre><code>sp&lt;MediaSource&gt; mVideoEncoder = OMXCodec::Create(client.interface(), omxEncMeta, true, mVideoOutSource); mVideoEncoder-&gt;start(); </code></pre> <p><code>mVideoOutSource</code> is my custom <code>MediaSource</code> class, <code>omxEncMeta</code> is the following:</p> <pre><code>int32_t colorFormat = OMX_COLOR_FormatYUV420SemiPlanar; int32_t width = 480; int32_t height = 360; int32_t frameRate = 24; int32_t bitRate = 500 * 1024; int32_t iFrameInterval = 1; sp&lt;MetaData&gt; omxEncMeta = new MetaData; omxEncMeta-&gt;setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC); omxEncMeta-&gt;setInt32(kKeyColorFormat, colorFormat); omxEncMeta-&gt;setInt32(kKeyWidth, width); omxEncMeta-&gt;setInt32(kKeyHeight, height); omxEncMeta-&gt;setInt32(kKeyStride, width); omxEncMeta-&gt;setInt32(kKeySliceHeight, height); omxEncMeta-&gt;setInt32(kKeyFrameRate, frameRate); omxEncMeta-&gt;setInt32(kKeySampleRate, frameRate); omxEncMeta-&gt;setInt32(kKeyBitRate, bitRate); omxEncMeta-&gt;setInt32(kKeyIFramesInterval, iFrameInterval); </code></pre> <p>but when I call <code>start()</code> method it returns the error code <code>UNKNOWN_ERROR</code>.</p> <p>Instead, if I try to give to <code>MPEG4Writer</code> directly my custom <code>MediaSource</code> (without wrapping it with <code>OMXCodec</code> it starts successfully but eventually it will stop recording with the error <code>Missing codec specific data</code> (after about 12 frames), and I think this is because my custom <code>MediaSource</code> provides only informations about the actual frames but nothing about the codec format.</p> <p>I'm sure I'm missing something with <code>OMXCodec</code>, but I can't figure out what... Is there anyone who could provide me with a working example of a custom <code>MediaSource</code> for encoding? Or give me some hints on why this is not working at all?<br> If you need more informations just ask, thanks!</p> <p><strong>EDIT</strong>: I'm developing this against API 14 so please don't suggest me to use <code>MediaCodec</code> from API 16 :)</p> <p><strong>EDIT</strong>: This is how I'm starting <code>MPEG4Writer</code>:</p> <pre><code>int32_t outputFormat = OUTPUT_FORMAT_MPEG_4; int64_t startTimeUs = systemTime() / 1000; int32_t totalBitRate = bitRate; sp&lt;MetaData&gt; meta = new MetaData; meta-&gt;setInt64(kKeyTime, startTimeUs); meta-&gt;setInt32(kKeyFileType, outputFormat); meta-&gt;setInt32(kKeyBitRate, totalBitRate); sp&lt;MPEG4Writer&gt; mWriter = new MPEG4Writer("/sdcard/encode_manual.mp4"); mWriter-&gt;addSource(mVideoEncoder); status_t error = mWriter-&gt;start(meta.get()); if (error != OK) { LOGE("Writer NOT started! %x", error); } else { LOGI("Writer started!"); } </code></pre> <hr> <p>This is the output of logcat (<code>adb logcat OMXClient:V OMXCodec:V *:W</code>):</p> <pre><code>W/ResourceType( 370): Skipping entry 0x7f04002f in package table 0 because it is not complex! E/ ( 4127): Can't open file for reading E/ ( 4127): Can't open file for reading E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): omx_video(): Inside Constructor() E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): omx_venc(): Inside component_init() E/OMX-VENC-720p( 155): bool venc_dev::venc_validate_profile_level(OMX_U32*, OMX_U32*): Returning with eProfile = 1Level = 4 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): bool venc_dev::venc_open(OMX_U32)(): Init Profile/Level setting success E/OMX-VENC-720p( 155): vidc.venc.debug.sliceinfo value is 0 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): Component_init return value = 0x0 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): WARNING: Requested i/p bufsize[40960],Driver's updated i/p bufsize = 262144 E/OMX-VENC-720p( 155): bool venc_dev::venc_validate_profile_level(OMX_U32*, OMX_U32*): Returning with eProfile = 1Level = 256 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): bool venc_dev::venc_set_param(void*, OMX_INDEXTYPE)(): Profile/Level setting success E/OMX-VENC-720p( 155): bool venc_dev::venc_validate_profile_level(OMX_U32*, OMX_U32*): Returning with eProfile = 1Level = 64 E/OMX-VENC-720p( 155): Calling set level (Framerate) with 15 E/OMX-VENC-720p( 155): bool venc_dev::venc_validate_profile_level(OMX_U32*, OMX_U32*): Returning with eProfile = 1Level = 64 E/OMX-VENC-720p( 155): Calling set level (Bitrate) with 15 E/OMX-VENC-720p( 155): get_parameter: OMX_IndexParamVideoProfileLevelQuerySupported for Input port returned Profile:1, Level:2048 E/OMX-VENC-720p( 155): Profile/Level set equal to 1/64 E/OMX-VENC-720p( 155): bool venc_dev::venc_validate_profile_level(OMX_U32*, OMX_U32*): Returning with eProfile = 1Level = 64 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): venc_set_intra_period: nPFrames = 25 nBFrames = 0 E/OMX-VENC-720p( 155): bool venc_dev::venc_validate_profile_level(OMX_U32*, OMX_U32*): Returning with eProfile = 1Level = 64 E/OMX-VENC-720p( 155): Calling set level (Bitrate) with 15 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): allocate_input_buffer():: E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): allocate_input_buffer():: E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): allocate_input_buffer():: E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): allocate_output_buffer():: E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): actual cnt = 5 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): allocate_output_buffer():: E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): actual cnt = 5 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): allocate_output_buffer():: E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): actual cnt = 5 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): allocate_output_buffer():: E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): actual cnt = 5 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): allocate_output_buffer():: E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): actual cnt = 5 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): unsigned int venc_dev::venc_start()(): Check Profile/Level set in driver before start E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): unsigned int venc_dev::venc_start()(): Driver Profile[3]/Level[15] successfully SET E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): ENC_CONFIG: Codec: 2, Profile 3, level : 15 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): ENC_CONFIG: Width: 480, Height:360, Fps: 25 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): ENC_CONFIG: Bitrate: 512000, RC: 3, I-Period: 25 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): ENC_CONFIG: qpI: 0, qpP: 80, qpb: 0 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): ENC_CONFIG: VOP_Resolution: 4343391, Slice-Mode: 1, Slize_Size: 0 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): ENC_CONFIG: EntropyMode: 1, CabacModel: 0 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): ENC_CONFIG: DB-Mode: 2, alpha: 0, Beta: 0 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): ENC_CONFIG: IntraMB/Frame: 18, HEC: 843271745 E/OMX-VENC-720p( 155): Width 480, Height 360, w_round 480, h_round 368, yuv_size 294912 alignment 8192 count 2 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): Allocated virt:0x4432e000, FD: 145 of size 294912 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): Allocated virt:0x4432e000, FD: 145 of size 294912 at index: 0 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): Allocated virt:0x44895000, FD: 147 of size 294912 E/OMX-VENC-720p( 155): E/OMX-VENC-720p( 155): Allocated virt:0x44895000, FD: 147 of size 294912 at index: 1 E/TestEnc-JNI( 4127): Writer NOT started! 80000000 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload