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
8
votes
1 answer

mediacodec vs mediaplayer and mediarecorder

I'm a bit confused about how to play and record video/audio in Android. I don't really understand in what situations one should use these classes: -To play: MediaPlayer vs MediaExtractor + MediaCodec -To record: MediaRecorder vs MediaCodec +…
Varu
  • 311
  • 1
  • 15
8
votes
1 answer

How to resample audio with AudioCodec?

I have PCM audio data with sample rate 48000, I want to encode audio to AAC with sample rate 44100? Is it possible to do so with MediaCodec?
Taras
  • 2,526
  • 3
  • 33
  • 63
8
votes
3 answers

Controlling Frame Rate of VirtualDisplay

I'm writing an Android application, and in it, I have a VirtualDisplay to mirror what is on the screen and I then send the frames from the screen to an instance of a MediaCodec. It works, but, I want to add a way of specifying the FPS of the encoded…
EncodedNybble
  • 265
  • 2
  • 11
8
votes
1 answer

What is the use of presentationTimeUs for MediaCodec?

The official definition for presentationTimeUs in queueInputBuffer (int index, int offset, int size, long presentationTimeUs, int flags) is the following: The presentation timestamp in microseconds for this buffer. This is normally the media time…
Hong
  • 17,643
  • 21
  • 81
  • 142
8
votes
2 answers

Decode mp4/h.264 using MediaCodec without MediaExtractor, expected access unit format

I am trying to use the MediaCodec API for decoding without using the MediaExtractor API. Instead, i use mp4parser to get the samples from the mp4 files. For now, i am only using h.264 / avc coded video content. The official documentation of the…
Bastian35022
  • 1,092
  • 1
  • 10
  • 18
8
votes
0 answers

Decoding h264 ByteStream on Android always gets INFO_TRY_AGAIN_LATER from dequeueOutputBuffer()

Trying to use the media codec to decode the encoded data gram packets but always gets -1 in dequeueOutputBuffer(). Please help me-what I'm doing wrong? I'm trying to face this problem for days without success. private void decodeVideo() { new…
dvrm
  • 3,749
  • 4
  • 34
  • 43
8
votes
1 answer

Decoding h264 ByteStream on Android

I want to decode and display a raw h264 video byte stream in Android and therefore I'm currently using the MediaCodec/Format classes. I acquire the frame data via Udp from a server. But, unfortunately, nothing is displayed at the moment. Here is…
Christoph
  • 606
  • 7
  • 21
8
votes
3 answers

Android MediaExtractor and mp3 stream

I am trying to play an mp3 stream using MediaExtractor/MediaCodec. MediaPlayer is out of the question due to latency and long buffer size. The only sample code i have found is this: http://dpsm.wordpress.com/category/android/ The code samples are…
8
votes
1 answer

MediaCodec get all frames from video

I'm trying to use the MediaCodec to retrive all the frames from a video for image processing stuff, I'm trying to render the video and to capture the frame from the outBuffers but I can't initiate a bitmap instance from the received bytes. I've…
Nativ
  • 3,092
  • 6
  • 38
  • 69
8
votes
1 answer

Buffering Surface input to MediaCodec

It's been demonstrated how to feed MediaCodec with Surface input like the CameraPreview, but are there practical ways of buffering this input before submission to MediaCodec? In my experiments, a Galaxy Nexus experiences unacceptable hiccups in…
dbro
  • 1,718
  • 1
  • 20
  • 34
7
votes
3 answers

Android MediaCodec realtime h264 encoding/decoding latency

I'm working with Android MediaCodec and use it for a realtime H264 encoding and decoding frames from camera. I use MediaCodec in synchronous manner and render the output to the Surface of decoder and everething works fine except that I have a long…
7
votes
0 answers

MediaCodec input buffer size is small for YUV_420_888 image format

I am using mediaCodec to convert images captured using camera2 api to videos. The problem arrived when I found YV12 isn't supported in some devices. When I used YV12 as input image format, and COLOR_FormatYUV420SemiPlanar as output, the size of…
Shivam Pokhriyal
  • 479
  • 4
  • 14
7
votes
2 answers

How to add Audio to Video while Recording [ContinuousCaptureActivity] [Grafika]

I implement Video recording using ContinuousCaptureActivity.java. it's work perfectly. Now i want to add Audio in this video. I know using MediaMuxer it is possible to add audio in video. But the problem is i don't know how to i use…
Ali
  • 3,346
  • 4
  • 21
  • 56
7
votes
2 answers

How to connect Android MediaCodec Surface to Vulkan

I have a pretty good understanding of decoding with Android MediaCodec and feeding YUV through a Surface into an OpenGL texture. I would like to do something similar with Vulkan. However I have not been successful in finding any documentation or…
Peter Tran
  • 1,626
  • 1
  • 17
  • 26
7
votes
2 answers

Hide a secure view completely in MediaProjection - android

I'm creating a screen recorder app using the MediaProjection API. In my app, I'm showing the stop button as a small overlay window. I've kept this view as secure so that it doesn't come up in the final recorded video. This view doesn't come up in…