mediacodec

How to provide both audio data and video data to MediaMux

情到浓时终转凉″ 提交于 2019-11-30 14:12:34
I'm trying to get video raw data by Preview, get audio raw data by AudioRecord. Then I will send them to MediaCodec(I will set two Codec instance). After that I will send the video data and audio data to MediaMux to get a mp4 file. I have two questions: 1) I've used MediaMux to process the video data before. For video data, the MediaMux process it by frame, but the video record is continuous. How could the MediaMux handle the video and audio in synchronization. 2) I found only of variable for inputbuffer in the function writeSampleData . A nice guy on StackOverflow also provided a demo of

[Android 进阶]MediaCodec简介

两盒软妹~` 提交于 2019-11-30 10:30:10
[Android 进阶]MediaCodec简介 由于前段时间单位处理过录屏直播之类的需求,这边首推的一个系列着力于MediaCodec,该系列包含下面几片文章: [Android 进阶]MediaCodec系列之MediaCodec简介 [Android 进阶]MediaCodec系列之MediaCodec+MediaEctractor播放器 [Android 进阶]MediaCodec+MediaProjection实现录制屏幕 [Android 进阶]MediaCodec+Camera API实现摄像头录制视频(上) [Android 进阶]MediaCodec+Camera API实现摄像头录制视频(下) 本篇文章是Google官方文档的翻译,其中生命周期的概念是我重新整理过的,原文地址: https://developer.android.google.cn/reference/android/media/MediaCodec.html MediaCodec是用来访问系统底层编解码器的一个类,通常与MediaExtractor, MediaSync, MediaMuxer, MediaCrypto, MediaDrm, Image, Surface, AudioTrack等一起使用。作为与底层编解码器交流的工作类,MediaCodec的一般数据流图如下[官网图]:

Android MediaExtractor and mp3 stream

▼魔方 西西 提交于 2019-11-30 09:35:38
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 only parcial (?) and use a File instead of a stream. I have been trying to adapt this example to play an Audio Stream but i can't get my head around how this is supposed to work. The Android documentation as usual is no help. I understand that first we get information about the stream, presumably setup the AudioTrack with this information ( code

OpenGL example to render bitmap to MediaCodec surface

一世执手 提交于 2019-11-30 09:34:04
问题 I am looking for an example on how to render a bitmap to the surface provided by MediaCodec so I can encode and then mux them into mp4 video. The closest well know example I see is this EncodeAndMuxTest. Unfortunately with my limited OpenGL knowledge I have not been able to convert the example to use bitmaps instead of the raw OpenGL Frames it currently generates. Here is the example's Frame generation Method. private void generateSurfaceFrame(int frameIndex) { frameIndex %= 8; int startX,

Resizing surface view for aspect ratio change in video display in android

大憨熊 提交于 2019-11-30 08:55:50
I am working on a video conferencing project. My video display is using surface view. Now during a video call there is a chance of aspect ratio change for the incoming frames. So i have tried the following code for it public void surfaceResize() { // WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Point size = new Point(); int screenWidth = 0; //Get the SurfaceView layout parameters float aspectRatio = (float) recv_frame_width / recv_frame_height; if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) { //Get the width of

Recording a Surface using MediaCodec

别来无恙 提交于 2019-11-30 08:51:11
So, In my application, I am able to show effects(like blur filter, gaussian) to video that comes from Camera using GPUImage library. Basically, I (library) will take the input from the Camera, get's the raw byte data, converts it into RGBA format from YUV format, then applies effects to this image and displays on the Surface of GLSurfaceView using OpenGL. finally, to the user, it looks like a video with effects applied. Now I want to record the frames of Surface as a video using MediaCodec API. but this discussion says that we can not pass a predefined Surface to the MediaCodec . I have seen

How to get bitmap (frames) from video using MediaCodec

余生颓废 提交于 2019-11-30 07:23:05
I'm trying to get all frames from video file using MediaCodec. If I try display video on SurfaceView, everything is ok. But if surface is null, and when I try get Bitmap from byte array, alwaus get null or runtime exception. This is my code: private class PlayerThread extends Thread { private MediaExtractor extractor; private MediaCodec decoder; private Surface surface; public PlayerThread(Surface surface) { this.surface = surface; } @Override public void run() { extractor = new MediaExtractor(); extractor.setDataSource(videoPath); for (int i = 0; i < extractor.getTrackCount(); i++) {

Select H264 Profile when encoding with MediaCodec and MTK Codec

爷,独闯天下 提交于 2019-11-30 05:27:08
问题 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 which gives a problem for the receiving device. I am using MediaCodec. There seems to be no way to set the profile to be used. Is there any way of doing this ? The codec does claim to support Baseline profile but gives no way of using it. Is there

Android MediaCodec: Reduce mp4 video size

北慕城南 提交于 2019-11-30 05:02:46
I am looking for a way to "compress" an mp4 video. To achieve this, I want to reduce the resolution of the video and / or reduce FPS. After long research, I think the way to do it is to use MediaCodec and related APIs as follows : -> MediaExtractor to extract encoded media data from a mp4 file. -> MediaCodec (Decoder): Decode each frame for later processing. -> MediaCodec (Encoder): At this point, I guess that's where we should establish MediaFormat parameters such as video resolution, which should help us to reduce the final size of the mp4 file. -> MediaMuxer for generate mp4 file (MinSDK 18

Muxing camera preview h264 encoded elementary stream with MediaMuxer

若如初见. 提交于 2019-11-30 04:56:23
问题 I am working on an implementation of one of the Android Test Cases regarding previewTexture recording with the new MediaCodec and MediaMuxer API's of Android 4.3. I've managed to record the preview stream with a framerate of about 30fps by setting the recordingHint to the camera paremeters. However, I ran into a delay/lag problem and don't really know how to fix that. When recording the camera preview with quite standard quality settings (1280x720, bitrate of ~8.000.000) the preview and the