mediacodec

Why the “MediaCodec CodecException” in “queueInputBuffer” only happen on Android API 29?

此生再无相见时 提交于 2020-06-17 06:28:07
问题 Basic Info targetSdkVersion 28 Goal : The objective of the class is to resize a video before sending to my server. Problem : The app crashes only on API 29, whether with real devices or using AVD. For example, the code works fine on Pixel 2 API 28 , but not on Pixel 2 API 29 Source Code : I use mostly the sample code from bigflake.com. Error message (detailed log are atteched below): E/AndroidRuntime: FATAL EXCEPTION: Thread-20 Process: com.myapp.myapp, PID: 9189 android.media.MediaCodec

Truncate video with MediaCodec

无人久伴 提交于 2020-06-14 02:48:59
问题 I've used Android MediaCodec library to transcode video files (mainly change the resolution Sample code here) Another thing I want to achieve is to truncate the video - to only take the beginning 15 seconds. The logic is to check videoExtractor.getSampleTime() if it's greater than the 15 seconds, I'll just write an EOS to the decoder buffer. But I get an exception Caused by: android.media.MediaCodec$CodecException: Error 0xfffffff3 Here is my code: while ((!videoEncoderDone) || (

Truncate video with MediaCodec

二次信任 提交于 2020-06-14 02:46:05
问题 I've used Android MediaCodec library to transcode video files (mainly change the resolution Sample code here) Another thing I want to achieve is to truncate the video - to only take the beginning 15 seconds. The logic is to check videoExtractor.getSampleTime() if it's greater than the 15 seconds, I'll just write an EOS to the decoder buffer. But I get an exception Caused by: android.media.MediaCodec$CodecException: Error 0xfffffff3 Here is my code: while ((!videoEncoderDone) || (

Truncate video with MediaCodec

南笙酒味 提交于 2020-06-14 02:45:07
问题 I've used Android MediaCodec library to transcode video files (mainly change the resolution Sample code here) Another thing I want to achieve is to truncate the video - to only take the beginning 15 seconds. The logic is to check videoExtractor.getSampleTime() if it's greater than the 15 seconds, I'll just write an EOS to the decoder buffer. But I get an exception Caused by: android.media.MediaCodec$CodecException: Error 0xfffffff3 Here is my code: while ((!videoEncoderDone) || (

使用MediaCodec和RTMP做直播推流

时光怂恿深爱的人放手 提交于 2020-04-06 07:41:02
目前开源的项目或市面上的Android直播客户端主要是用ffmpeg来实现推流的。本文将介绍使用Android原生的视频编码类MediaCodec实现直播推流。 数据流及大致原理 这里所说的直播,就是将你的客户端产生的视频数据,实时发送到服务器上。服务器上的数据再实时地发送到播放客户端上。 以视频数据为例: 获取Camera画面 首先是摄像头拍摄得到原始画面数据,这里原始画面数据的格式我们不用管,因为我们使用的是MediaCodec,所以我们会使用 camera.setPreviewTexture(surfaceTexture) 来利用Camera获取到的画面。 此处的原理可忽略,大致说明的话,就是Camera会把获得的画面保存为OpenGL的一个纹理,我们使用这个纹理就能使用Camera的画面。 绘制画面 在获得画面之后,我们要把这个画面(纹理)“画”到MediaCodec上。 如何画? MediaCodec提供一张’白纸’,也就是一个Surface,供我们把纹理画到上面。此处的API是 MediaCodec.createInputSurface() 怎么画?用Canvas画。当然不是一般的Canvas,我用了这个开源项目android-openGL-canvas。 H264数据 画上去后,MediaCodec就会帮我们把原始画面数据,压缩成相应的视频数据

Android MediaCodec appears to buffer H264 frames

我只是一个虾纸丫 提交于 2020-03-20 05:00:58
问题 I'm manually reading a RTP/H264 stream and pass the H264 frames to the Android MediaCodec. I use the "markerBit" as a border for the frames. The MediaCodec is tied to a OpenGL Texture (SurfaceTexture). In general everything works fine. But the Decoder appears to buffer frames. If I put a frame in the decoder it is not rendered immediately to the texture. After I put 2-3 frames more in the decoder the first frame is rendered to the texture. I'm implementing against Android 4.4.4. private

Android MediaCodec appears to buffer H264 frames

♀尐吖头ヾ 提交于 2020-03-20 04:58:34
问题 I'm manually reading a RTP/H264 stream and pass the H264 frames to the Android MediaCodec. I use the "markerBit" as a border for the frames. The MediaCodec is tied to a OpenGL Texture (SurfaceTexture). In general everything works fine. But the Decoder appears to buffer frames. If I put a frame in the decoder it is not rendered immediately to the texture. After I put 2-3 frames more in the decoder the first frame is rendered to the texture. I'm implementing against Android 4.4.4. private

Android MediaCodec appears to buffer H264 frames

你离开我真会死。 提交于 2020-03-20 04:55:09
问题 I'm manually reading a RTP/H264 stream and pass the H264 frames to the Android MediaCodec. I use the "markerBit" as a border for the frames. The MediaCodec is tied to a OpenGL Texture (SurfaceTexture). In general everything works fine. But the Decoder appears to buffer frames. If I put a frame in the decoder it is not rendered immediately to the texture. After I put 2-3 frames more in the decoder the first frame is rendered to the texture. I'm implementing against Android 4.4.4. private

MediaCodec - strange error when sending EOS buffer into audio decoder

帅比萌擦擦* 提交于 2020-03-19 07:49:58
问题 I'm working on replacing the audio track of my video with music from another file. So I modified the standard ExtractDecodeEditEncodeTest code (from bigflake) so that the audio MediaExtractor is created from said 'another file'. A strange thing happens when I try to send an EOS buffer into the audio decoder, however, in this line: this.audioDecoder.queueInputBuffer(decoderInputBufferIndex, 0, 0, 0, MediaCodec.BUFFER_FLAG_END_OF_STREAM); This netted me an android.media.MediaCodec

how to reduce MediaCodec H264 encoder latency

我的梦境 提交于 2020-02-28 07:04:58
问题 I'm trying to encode h264 into stream in real-time low latency with Android6.0's MediaCodec. There are about 6 frames latency from encoder which I wanna know how to reduce Codes are from screenrecord.cpp part codes are: while (true) { encoder->dequeueOutputBuffer(&bufIndex); } the encoder is feed by Surface of screen in 320x480 60 fps, and it outputs stream data by dequeueOutputBuffer(). There are about 6 frames feed to encoder whose data are not return immedately by dequeueOutputBuffer(). In