passing bytebuffer to ffmpeg

118 views
Skip to first unread message

kjhari02

unread,
Mar 23, 2011, 10:05:19 PM3/23/11
to android-ndk
Hi All,

I'm trying my hands on ffmpeg and am stuck on how I pass the
bytebuffer to the ffmpeg method avcodec_decode_audio3.

The method declaration for is 'avcodec_decode_audio3' is

avcodec_decode_audio3(AVCodecContext *avctx, int16_t *samples, int
*frame_size_ptr, AVPacket *avpkt)

Has anyone done this before.

Can someone throw some light on this?

Regards,
Hari

appforce.org

unread,
Mar 24, 2011, 2:52:24 AM3/24/11
to android-ndk
If your ByteBuffer has an array backend (you created it by the wrap()
static method) you can pass the byte[] array to native code and access
it by JNI's GetByteArrayElements/ReleaseByteArrayElements. Keep in
mind that you should sum the return value of avcodec_decode_audio3 and
keep calling that function until the sum reaches avpkt->size. That's
because in some scenarios there can be more than one audio frame in
one AVPacket.
Reply all
Reply to author
Forward
0 new messages