HarmonyOS 鸿蒙Next音频编码报错,返回值AV_ERR_INVALID_VAL

发布于 1周前 作者 nodeper 来自 鸿蒙OS

HarmonyOS 鸿蒙Next音频编码报错,返回值AV_ERR_INVALID_VAL
<markdown _ngcontent-pck-c237="" class="markdownPreContainer">


void BaseAudioEncoder::encFunc(void* inputBuffer,size_t inputLength) const
{
unique_lock<mutex> lock(signal_->inMutex_);
signal_->inCond_.wait(lock, this { return (signal_->inQueue_.size() > 0); });

uint32_t index = signal_-&gt;inQueue_.front();
<span class="hljs-keyword"><span class="hljs-keyword">auto</span></span> buffer = signal_-&gt;inBufferQueue_.front();
<span class="hljs-built_in"><span class="hljs-built_in">stringstream</span></span> ss1;
ss1 &lt;&lt; index &lt;&lt; <span class="hljs-string"><span class="hljs-string">" size = "</span></span> &lt;&lt; inputLength;
OH_AVCodecBufferAttr attr = {<span class="hljs-number"><span class="hljs-number">0</span></span>};
attr.size = inputLength;
attr.flags = AVCODEC_BUFFER_FLAGS_NONE;

uint8_t *bufferAddr = OH_AVBuffer_GetAddr(buffer);
<span class="hljs-built_in"><span class="hljs-built_in">memcpy</span></span>(bufferAddr, inputBuffer, inputLength);

OH_AVBuffer_SetBufferAttr(buffer, &amp;attr);
 <span class="hljs-comment"><span class="hljs-comment">// 送入编码输入队列进行编码, index为对应队列下标</span></span>
OH_AVErrCode ret = OH_AudioCodec_PushInputBuffer(audioEnc_, index);
ss1 &lt;&lt; <span class="hljs-string"><span class="hljs-string">" ret = "</span></span> &lt;&lt; ret;
printLog(ss1.str().c_str());
 <span class="hljs-keyword"><span class="hljs-keyword">if</span></span> (ret != AV_ERR_OK) {
     printLog(<span class="hljs-string"><span class="hljs-string">"encodePCMNative failed"</span></span>);
 }

} <button style="position: absolute; padding: 4px 8px 0px; cursor: pointer; top: 4px; right: 8px; font-size: 14px;">复制</button>

最后调用OH_AudioCodec_PushInputBuffer报错,有知道怎么回事的吗?

</markdown>

关于HarmonyOS 鸿蒙Next音频编码报错,返回值AV_ERR_INVALID_VAL的问题,您也可以访问:https://www.itying.com/category-93-b0.html 联系官网客服。
回到顶部