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

Encoder crash on Adreno GPU while encoding from Surface

I've been struggling with this issue for more than a week, and most likely it is a bug in the Qualcomm GPU/hardware video encoder. Since we are pressed to release the application, and their developer forums did not provide any feedback, I am posting…
user1592546
  • 1,480
  • 1
  • 14
  • 30
61
votes
1 answer

Encoding and muxing video using MediaCodec and MediaMuxer

I am developing an App where I decode a video and replace certain frames and re-encode using MediaMuxer and MediaCodec. The App works if I do not replace any frames (except for 1080p videos as I explain below), but when I do, the frames after the…
Mohamed_AbdAllah
  • 5,311
  • 3
  • 28
  • 47
33
votes
4 answers

Adding watermark bitmap over video in android: 4.3's MediaMuxer or ffmpeg

Here is my scenario: Download an avi movie from the web Open a bitmap resource Overlay this bitmap at the bottom of the movie on all frames in the background Save the video on extarnal storage The video length is 15 seconds usually Is this…
Alin
  • 14,809
  • 40
  • 129
  • 218
30
votes
0 answers

Handle MediaCodec video with dropped frames

I'm currently doing fast precise seeking using MediaCodec. What I currently do to skip frame by frame is, I first get the total frames: mediaInfo.totalFrames = videoTrack.getSamples().size(); Then I get the length of the video…
ClassA
  • 2,480
  • 1
  • 26
  • 57
24
votes
1 answer

MediaCodec getInputImage return null on Some Devices

I want to encode using MediaCodec by setting color format to COLOR_FormatYUV420Flexible. My Input buffer's is yuv420p.When I input buffer like this : int inputBufferIndex = mEncoder.dequeueInputBuffer(-1); mCurrentBufferIndex =…
ene
  • 257
  • 1
  • 8
24
votes
2 answers

How to use MediaCodec without MediaExtractor for H264

I need to use MediaCodec without the MediaExtractor and I'm reading the file using a FileInputStream. Currently it is not working, it is showing a greenish scrambled image on the screen. This is the whole source code: FileInputStream in = new…
thiagolr
  • 6,909
  • 6
  • 44
  • 64
24
votes
2 answers

Android MediaCodec AAC encoder

I use the MediaCodec class provided by the Android SDK since API level 16 with the OMX.SEC.aac.enc encoder to encode audio to a file. I get the audio input from the AudioRecord class. My instance of the AudioRecord class is configured like…
user2144883
23
votes
2 answers

Android MediaCodec Encode and Decode In Asynchronous Mode

I am trying to decode a video from a file and encode it into a different format with MediaCodec in the new Asynchronous Mode supported in API Level 21 and up (Android OS 5.0 Lollipop). There are many examples for doing this in Synchronous Mode on…
23
votes
1 answer

MediaExtractor, MediaMetadataRetriever with Raw/Asset File

I try to read a video file inside either raw/assets folder, I have tried the following approaches but none of them works. I am testing on API 16. Each approach, I try with and without mp4 extension. I really appreciate that somebody can help me with…
vodkhang
  • 18,639
  • 11
  • 76
  • 110
23
votes
1 answer

SurfaceTexture's onFrameAvailable() method always called too late

I'm trying to get the following MediaExtractor example to work: http://bigflake.com/mediacodec/ - ExtractMpegFramesTest.java (requires 4.1, API 16) The problem I have is that outputSurface.awaitNewImage(); seems to always throw…
manixrock
  • 2,533
  • 4
  • 24
  • 29
23
votes
1 answer

How to generate the AAC ADTS elementary stream with Android MediaCodec

What I am trying to do: use Android's MediaCodec to encode raw PCM audio samples into a raw AAC file. The problem I have: when I use FFMPEG to pack the generated raw AAC file into an M4A container, FFMPEG complains about missing codec parameters in…
hubeir
  • 1,279
  • 2
  • 13
  • 24
22
votes
1 answer

Android - Choosing between MediaRecorder, MediaCodec and Ffmpeg

I am working on a video recording and sharing application for Android. The specifications of the app are as follows:- Recording a 10 second (maximum) video from inside the app (not using the device's camera app) No further editing on the video…
Rohan Stark
  • 2,346
  • 9
  • 16
22
votes
6 answers

PCM -> AAC (Encoder) -> PCM(Decoder) in real-time with correct optimization

I'm trying to implement AudioRecord (MIC) -> PCM -> AAC Encoder AAC -> PCM Decode -> AudioTrack?? (SPEAKER) with MediaCodec on Android 4.1+ (API16). Firstly, I successfully (but not sure correctly optimized) implemented PCM -> AAC Encoder by …
user1028880
19
votes
1 answer

Images to Video using MediaCodec and MediaMuxer

I have a bunch of local images saved as jpeg files. My images are captured using CameraPreview and the PreviewFormat is as default: NV21. I want to generate a small video from a fixed number of images. I am not going to use FFMpeg because it…
Fanglin
  • 2,132
  • 1
  • 21
  • 26
18
votes
2 answers

Encoding AAC Audio using AudioRecord and MediaCodec on Android

I am trying to encode aac audio using android AudioRecord and MediaCodec. I have created a encoder class very similar to (Encoding H.264 from camera with Android MediaCodec). With this class, I created an instance of AudioRecord and tell it to read…
xiaowoo
  • 2,248
  • 7
  • 34
  • 45
1
2 3
78 79