Questions tagged [android-mediacodec]

MediaCodec is a class from the package "android.media" of Android API that can be used to access low-level, native media codec, i.e. encoder/decoder components.

MediaCodec is a class from the package android.media of Android API that can be used to access low-level, native media codec, i.e. encoder/decoder components. Along with the common IO it supports input data of the following decoder mime types:

  • "video/x-vnd.on2.vp8" - VPX video (i.e. video in .webm)
  • "video/avc" - H.264/AVC video
  • "video/mp4v-es" - MPEG4 video
  • "video/3gpp" - H.263 video
  • "audio/3gpp" - AMR narrowband audio
  • "audio/amr-wb" - AMR wideband audio
  • "audio/mpeg" - MPEG1/2 audio layer III
  • "audio/mp4a-latm" - AAC audio
  • "audio/vorbis" - vorbis audio
  • "audio/g711-alaw" - G.711 alaw audio
  • "audio/g711-mlaw" - G.711 ulaw audio

The reference to the API docs: http://developer.android.com/reference/android/media/MediaCodec.html

1173 questions
6
votes
1 answer

Android MediaCodec dequeueInputBuffer always returns -1

I'm trying to take raw data from the AudioRecord object and save it in a file using a MediaMuxer and MediaCodec. I start the codec, start the muxer, load data into the input buffers and no such luck. From debugging investigation, I've found that…
6
votes
1 answer

OMX.qcom encoder random crash

The app is based on Grafika's camera capture activity (https://github.com/google/grafika/tree/master/src/com/android/grafika). The user taps on a button to record a video. A random crash is happening on Nexus 5x. Posted below are 2 logs of when it…
Ziad Halabi
  • 964
  • 11
  • 31
6
votes
0 answers

Android MediaCodec encode raw video to h264

I'm trying to convert my phone camera output to .h264 es format but MediaCodec encoder stuck on TRY_AGAIN_LATER output buffer state after first frame.Camera preview is setted to NV21. Here is camera-to-encoder: mCamera.setPreviewCallback(new…
Max Plakhuta
  • 310
  • 2
  • 14
6
votes
1 answer

Android MediaExtractor readSampleData IllegalArgumentException

I try to follow this question Concatenate multiple mp4 audio files using android´s MediaMuxer and concatenate video files. But for some reason, the MediaExtractor throws an IllegalArgumentException when I call the readSampleData In the official API,…
Taiko
  • 1,351
  • 1
  • 19
  • 35
6
votes
0 answers

How can I extract rtsp data into MediaCodec

I am having issues with MediaPlayer playing my RTSP stream, so i decided to use the lower level APIs - MediaExtractor and MediaCodec. The problem is that the setDataSource() method for MediaExtractor does not accept an RTSP stream. So, my question…
JoeyZee
  • 165
  • 1
  • 8
6
votes
1 answer

Video rendering is broken MediaCodec H.264 stream

I am implementing a decoder using MediaCodec Java API for decoding live H.264 remote stream. I am receiving H.264 encoded data from native layer using a callback (void OnRecvEncodedData(byte[] encodedData)), decode and render on Surface of…
Kaidul
  • 15,409
  • 15
  • 81
  • 150
6
votes
1 answer

How do I use the new MediaCodec getInputBuffer(int index)

I have an example that I am working from for decoding mp3 audio with MediaCodec for playing using MediaPlayer and AudioTrack. The example is using getInputBuffers() which is now depricated in API 21+. The new getInputBuffer(int index) returns one…
6
votes
1 answer

How to mix two audio samples and encode back to audio file using MediaMuxer

I currently have two separate media extractors and codecs that I am using to break down each individual sample into ByteBuffers. Then I store each sample into two short arrays. Then I call my mix function which combines the two samples into one…
AMG
  • 117
  • 7
6
votes
1 answer

Record video with MediaCodec and MediaMuxer, but the bitrate and framerate are incorrect

I wrote a demo to record a video using MediaCodec and MediaMuxer. I record a video with my demo and use ffprobe to check the video, the result is as follows: Duration: 00:00:06.86, start: 0.000000, bitrate: 723 kb/s Stream #0:0(eng): Video: h264…
dragonfly
  • 1,151
  • 14
  • 35
6
votes
2 answers

Record video and audio from a GLSurfaceView and export it to .mp4

I am a newbie in OpenGL. I want to record video and audio from a GLSurfaceView and export it to .mp4 (or other formats). I have a GlsurfaceView that implement Renderer I've tried using fadden examples's in bigflake.com like EncodeAndMuxTest.java ,or…
leon
  • 942
  • 11
  • 15
6
votes
1 answer

Using renderscript for processing and mediacodec for encoding

I am trying to develop a camera app that does some video processing before recording the video. I have decided to use Rendrscript for the processing since it provides many of the operations that I want to use. And I want to use MediaCodec for…
Phyxle
  • 61
  • 2
6
votes
1 answer

Displaying h264 video from an mpegts stream over udp:// on android

Displaying h264 video from an mpegts stream over udp:// on android. I've been trying for a few days to get this to work with no success. What I have is a device that produces a h264 video stream that it multicasts over in an mpegts container over…
bj0
  • 7,893
  • 5
  • 38
  • 49
6
votes
1 answer

CameraToMpegTest.java is not working, ends with IllegalStateException: Can't stop due to wrong state

I have a problem running CameraToMpegTest.java from http://bigflake.com/mediacodec/. When I start it from the Activity: public class MyActivity extends Activity { private CameraToMpegTest ctmt = new CameraToMpegTest(); ... @Override …
Erniecz
  • 65
  • 1
  • 4
6
votes
3 answers

Select H264 Profile when encoding with MediaCodec and MTK Codec

We have an Android app that encodes video into H264. On all previously tried Android devices this encodes to Baseline profile which is what I need. On the Lenovo Yoga 10 the codec is OMX.MTK.VIDEO.ENCODER.AVC. This encodes the video as High Profile…
Paul Jackson
  • 61
  • 1
  • 3
6
votes
2 answers

What are valid bit rates to set for MediaCodec

I'm using MediaCodec to encode video from the camera: MediaFormat format = MediaFormat.createVideoFormat("video/avc", width, height); format.setInteger(MediaFormat.KEY_BIT_RATE, 250000); …
David
  • 27,652
  • 18
  • 89
  • 138