Hi All,

I am trying to get RAW YV12 frames (from onPreviewFrame) and convert the
same the H.264, using MediaCodec class.  So far i have not been able to
convert the H.264 successfully.  The reason being not sure how to extract
the NAL (SPS and PPS ) info and add it to the Encoder.   My sample code for
deque is as below.


            final int TIMEOUT_USEC = 100;
            byte idrFrameType = 0x65;
            if (VERBOSE) Log.d(TAG, "drainEncoder(" + endOfStream + ")");
            ByteBuffer[] outputBuffers = encoder.getOutputBuffers();
            int outputBufferIndex = encoder.dequeueOutputBuffer(bufferInfo,0);
            while (outputBufferIndex >= 0) {
                ByteBuffer outputBuffer = outputBuffers[outputBufferIndex];
                byte[] outData = new byte[bufferInfo.size];
                outputBuffer.get(outData);
                try {
                    stream.write(outData);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                Log.d("AvcEncoder", outData.length + " bytes written");

                encoder.releaseOutputBuffer(outputBufferIndex, false);
                outputBufferIndex = encoder.dequeueOutputBuffer(bufferInfo, 0);
            }



I have even tried the INFO_OUTPUT_FORMAT_CHANGED but that didnt help
either.   Currently i am writing the data to a file, but the big
picture is to stream to a server.  When i try to play the save file
with the default android player it never plays.


Thanks,

Ankur.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to