mediamuxer

How to record video and audio with MediaCodec and MediaMuxer

自古美人都是妖i 提交于 2019-12-08 22:03:36
问题 I am able to record(encode) video with the help of MediaCodec and MediaMuxer. Next, I need to work on audio part and mux audio with video with help of MediaCodec and MediaMuxer. I am facing two problems: How to encode audio with MediaCodec. Do I need to encode audio and video in separate threads? How can I pass audio and video data to MediaMuxer (as writeSampleData() method takes only one type of data at a time)? I referred to MediaMuxerTest but it is using MediaExtractor. I need to use

MediaMuxer.nativeWriteSampleData always peroidically blocks for about one second during video recording

末鹿安然 提交于 2019-12-06 08:36:52
I am doing android video recording using mediacodec + mediamuxer, and now I can record video and generate mp4 file which can be played. The problem is that I find the recorded video will seize for about one second some time. So I launched traceview and I find MediaMuxer.nativeWriteSampleData() cause the problem. Sometimes this function is very fast and returns within several micro-seconds, but sometimes this function is very slow and will consume about one second or so, and the video blocks at that time. I do not know why this function will perform so varying from time to time. The recording

How can I trim a video from Uri, including files that `mp4parser` library can handle, but using Android's framework instead?

巧了我就是萌 提交于 2019-12-04 23:10:48
Background Over the past few days, I've worked on making a customizable, more updated version of a library for video trimming, here (based on this library ) The problem While for the most part, I've succeeded making it customizable and even converted all files into Kotlin, it had a major issue with the trimming itself. It assumes the input is always a File, so if the user chooses an item from the apps chooser that returns a Uri, it crashes. The reason for this is not just the UI itself, but also because a library that it uses for trimming ( mp4parser ) assumes an input of only File (or

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:

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)

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

Android: MediaCodec: bad video generated on Nexus for 480x480 while 640x640 works well

时间秒杀一切 提交于 2019-11-30 20:43:27
问题 I am rendering an Mpeg4/avc video on android using the MediaCodec (and MediaMuxer). I'm testing on both LG Nexus 4 & Samsung Galaxy 5. On samsung, the rendered video looks as expected for both 640x640 and 480x480 frame size. BUT, on the Nexus, 480x480 generates a bad looking video, while the 640x640 generates a good video. Quesion is: what is the reason? is this a bug or a "feature" I am not aware of. Is there a well-known frame size we can rely on being rendered correcly on all Android

How to trim video with MediaCodec

萝らか妹 提交于 2019-11-30 16:33:00
I'm trying to record the screen with MediaProjection API. I want to trim the video that was recorded by the media projection. Is there a way to do that without using any 3rd party dependency? mnagy After lots of digging, I found this snippet /** * @param srcPath the path of source video file. * @param dstPath the path of destination video file. * @param startMs starting time in milliseconds for trimming. Set to * negative if starting from beginning. * @param endMs end time for trimming in milliseconds. Set to negative if * no trimming at the end. * @param useAudio true if keep the audio track

Concatenate multiple mp4 audio files using android´s MediaMuxer

纵饮孤独 提交于 2019-11-29 12:08:07
I am trying to concatenate multiple mp4 audio files (each containing only one audio track, all recorded with the same MediaRecorder and the same parameters) into one using the following function: @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) public static boolean concatenateFiles(File dst, File... sources) { if ((sources == null) || (sources.length == 0)) { return false; } boolean result; MediaExtractor extractor = null; MediaMuxer muxer = null; try { // Set up MediaMuxer for the destination. muxer = new MediaMuxer(dst.getPath(), MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4); // Copy the

MediaMuxer fails to stop if csd-1 not exist

拥有回忆 提交于 2019-11-28 10:59:27
问题 I am using MediaExtractor to extract video and audio tracks from a Video file and then feed them again to a MediaMuxer . The code works fine if extracted Media format contains both csd-0 and csd-1 and the converted video is working nicely. However, some videos only have csd-0 only and these videos cause the application to crash at MediaMuxer.stop() . Here is the stack trace: V/ACodec(5925) [OMX.Exynos.mpeg4.enc] Now Executing->Idle V/ACodec(5925) [OMX.Exynos.mpeg4.enc] saw error -1011 instead