mediacodec

What governs playback speed when encoding with Android's MediaCodec + mp4parser?

心已入冬 提交于 2019-12-02 11:15:28
I'm trying to record, encode and finally create a short movie on Android (using API 16) with a combination of MediaCodec and Mp4Parser (to encapsulate into .mp4). Everything is working just fine, except for the duration of the .mp4: its always 3 seconds long - and runs at about twice the 'right' speed. The input to encoder is 84 frames (taken 100ms apart). The last frame sets the 'end of stream' flag. I set the presentation time for each frame on queueInputBuffer I've tried to tweak every conceivable parameter - but nothing seems to make a difference - the film is always 3 seconds long - and

Running ExtractDecodeEditEncodeMuxTest outside of testcase on Android

[亡魂溺海] 提交于 2019-12-02 08:29:21
问题 I am trying to add functionality to extract, decode, edit, encode and mux a video on Android. Therefore, I found some very useful implementation, which is part of the Android CTS ExtractDecodeEditEncodeMuxTest. Unfortunately, the code only works if it is executed as part of the testcase. I tried to execute it from a normal activity and get: E/ExtractDecodeEditEncodeMuxTest (18781): java.lang.IllegalStateException: Failed to stop the muxer W/System.err(18781): java.lang.RuntimeException:

ACodec从UninitializedState状态到LoadedState状态分析

元气小坏坏 提交于 2019-12-02 08:10:59
一、引言: 本博客涉及的内容是mediacodec从create到config过程中native层的逻辑分析,mediacodec在应用层的逻辑时序图如下(create->start): 二、create的native层代码分析: 进入到native层之后,mediacodec会先去实例化本体对象,然后执行init操作, init函数关键代码贴出如下: MediaCodec . cpp status_t MediaCodec :: init ( const AString & name , bool nameIsType , bool encoder ) { . . . /* 1.实例化ACodec */ mCodec = new ACodec ; . . . /* 2.在MediaCodec中实例化一个ALooper,用于ACodec进行消息传送 */ if ( needDedicatedLooper ) { if ( mCodecLooper == NULL ) { mCodecLooper = new ALooper ; mCodecLooper - > setName ( "CodecLooper" ) ; mCodecLooper - > start ( false , false , ANDROID_PRIORITY_AUDIO ) ; } mCodecLooper -

Running ExtractDecodeEditEncodeMuxTest outside of testcase on Android

狂风中的少年 提交于 2019-12-02 07:24:25
I am trying to add functionality to extract, decode, edit, encode and mux a video on Android. Therefore, I found some very useful implementation, which is part of the Android CTS ExtractDecodeEditEncodeMuxTest . Unfortunately, the code only works if it is executed as part of the testcase. I tried to execute it from a normal activity and get: E/ExtractDecodeEditEncodeMuxTest (18781): java.lang.IllegalStateException: Failed to stop the muxer W/System.err(18781): java.lang.RuntimeException: Surface frame wait timed out W/System.err(18781): at ...OutputSurface.awaitNewImage(OutputSurface.java:216)

使用MediaExtractor+MediaCodec+MediaMuxer实现视频截取和拼接

…衆ロ難τιáo~ 提交于 2019-12-02 05:53:26
Android中使用MediaExtractor+MediaCodec+MediaMuxer实现将本地视频解码截取再和另外的视频进行拼接编码合成一个视频,主要有两个类。 下面是解码相关的类VideoDecoder.java package com . audiovideo . camera . decoder ; import android . media . MediaCodec ; import android . media . MediaCodecInfo ; import android . media . MediaCodecList ; import android . media . MediaExtractor ; import android . media . MediaFormat ; import android . os . Handler ; import android . os . HandlerThread ; import android . support . annotation . NonNull ; import android . util . Log ; import android . widget . Toast ; import com . audiovideo . camera . MyApplication ;

Problems with MediaExtractor

十年热恋 提交于 2019-12-02 05:24:58
问题 I am trying to get specific frames at specific times as images from a movie using MediaExtractor and MediaCodec . I can do it successfully if: I use extractor.seekTo(time, MediaExtractor.SEEK_TO_PREVIOUS_SYNC); , however, this only gives the nearest sync frame not the target frame. I sequentially extract all frames using extractor.advance(); , but I need to get the target frame not all. So, I try the following: extractor.seekTo(time, MediaExtractor.SEEK_TO_PREVIOUS_SYNC); while(extractor

Maximum playable video resolution on Android

北慕城南 提交于 2019-12-02 03:56:31
问题 Is there a way to extract the maximum video resolution Android can play? We have MP4 files we download from the camera and I would like to show some error to the user before playing. Because if the resolution is too high, Android will just give you a black screen. I tried using the camcorder profile, but this one is giving me most of the time 1920x1080 even on devices that can handle higher resolutions such as the Galaxy S5. CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); Any help is

MediaCodec.dequeueOutputBuffer taking very long when encoding h264 on Android

流过昼夜 提交于 2019-12-02 01:21:22
问题 I'm trying to encode h264 video on Android for real-time video streaming using MediaCodec but dequeueOutputBuffer keeps taking very long (actually it's very fast sometimes but very slow at other times, see log output below). I've seen it go even up to 200ms for the output buffer to be ready. Is there something I'm doing wrong with my code or do you think this is an issue with the OMX.Nvidia.h264.encoder? Maybe I need to downsample the image from 1280x720 to something smaller? Or maybe I need

Maximum playable video resolution on Android

白昼怎懂夜的黑 提交于 2019-12-02 00:50:00
Is there a way to extract the maximum video resolution Android can play? We have MP4 files we download from the camera and I would like to show some error to the user before playing. Because if the resolution is too high, Android will just give you a black screen. I tried using the camcorder profile, but this one is giving me most of the time 1920x1080 even on devices that can handle higher resolutions such as the Galaxy S5. CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH); Any help is really appreciated! Florian Okay, on Android Lollipop you can use this, MediaCodecInfo.VideoCapabilities

Android MediaMuxer failed to stop

一个人想着一个人 提交于 2019-12-02 00:01:34
问题 I am trying to use MediaCodec,MediaExtractor and MediaMuxer to generate mp4 file. EveryThing seems to work properly but when i call MediaMuxer.stop i'm having an error . The MP4 file is created but i can't play it with a Player. Here is my logcat: 02-13 10:41:22.420: D/OpenGLRenderer(11768): Enabling debug mode 0 02-13 10:41:22.600: I/OMXClient(11768): Using client-side OMX mux. 02-13 10:41:22.717: E/ACodec(11768): [OMX.TI.DUCATI1.VIDEO.DECODER] storeMetaDataInBuffers failed w/ err