mediaextractor

Use MediaCodec and MediaExtractor to decode and code video

妖精的绣舞 提交于 2020-01-12 03:57:06
问题 I need to decode a video into a sequence of bitmaps, such that I am able to modify them, and then compress them back to a video file in android. I plan to manage this by using getFrameAtTime and saving it to an image sequence. Then I can modify images in the sequence and code it back to a movie. But I have two problem with this: First, as I read it, the getFrameAtTime is for creating thumbnails and will not guarantee returning the correct frame. This makes the video laggy. Secondly, saving

Is there a way to get the total number of video frames on Android?

匆匆过客 提交于 2020-01-04 19:49:30
问题 I am currently extracting, decoding, editing and re-encoding a video on Android using MediaCodec and MediaExtractor on Android. In the course of this process I would like to give users some information on the progress. I am already counting how many frames were extracted, decoded and encoded. In order to compute a percentage and to show users how far the process is, I would need the total number of frames in the original stream. However, I am unable to find a method in the MediaExtractor.

Android MediaExtractor seek() accuracy with MP3 audio files

馋奶兔 提交于 2020-01-02 18:04:07
问题 I am having trouble getting reasonable accuracy on seek() with Android MediaExtractor . For some files, such as this one, I find significant inaccuracies (about 3 seconds in this case.) I have the following flow: call setDataSource() and selectTrack() call seekTo() call play() In this case, it seeks to an incorrect position, but reports the correct position. If I then seek to another position, it continues to be off by the same margin. However, if I seek to 0, it corrects itself, and then

Decrypting widevine DRM protected video in android using MediaDrm

时间秒杀一切 提交于 2020-01-02 13:33:50
问题 I am trying to decrypt widevine DRm protected media file using Android's MediaDrm API. But MediaDrm is instantiated using UUId( of DRM-scheme). Android developer site says "App accesses the DRM-scheme-identifying UUID, typically from metadata in the content, and uses this UUID to construct an instance of a MediaDrm object that is able to support the DRM scheme required by the content". (www.developer.android.com/reference/android/media/MediaDrm.html). So I tried to get UUID using

Decrypting widevine DRM protected video in android using MediaDrm

∥☆過路亽.° 提交于 2020-01-02 13:32:52
问题 I am trying to decrypt widevine DRm protected media file using Android's MediaDrm API. But MediaDrm is instantiated using UUId( of DRM-scheme). Android developer site says "App accesses the DRM-scheme-identifying UUID, typically from metadata in the content, and uses this UUID to construct an instance of a MediaDrm object that is able to support the DRM scheme required by the content". (www.developer.android.com/reference/android/media/MediaDrm.html). So I tried to get UUID using

Recoding one H.264 video to another using opengl surfaces is very slow on my android

喜你入骨 提交于 2020-01-01 19:58:53
问题 I'm developing function of translating one video into another with additional effects for each frame. I decided to use opengl-es for applying effects on each frame. My input and output videos are in MP4 using H.264 codec. I use MediaCodec API (android api 18+) for decoding H.264 into the opengl texture, then draw on the surface using this texture with my shader. I thought that using MediaCodec with H.264 will do hardware decoding on android and it will be fast. But appeared that it is not.

Decoding Video and Encoding again by Mediacodec gets a corrupted file

三世轮回 提交于 2019-12-29 06:28:58
问题 I am trying to implement https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/DecodeEditEncodeTest.java but modifying the source by using a video file mp4. The mime tipe is video/avc, bitrate 288kbps, iframeinterval 100, width: 176, height: 144. The file size is 6MB. When I decode the video and put the frame in the outputsurface, I can save the frame to a bitmap and see the frame great. But at the end, after encoding (with the same parameters

audio codec dequeueInputBuffer returns -1 on device

隐身守侯 提交于 2019-12-25 05:27:40
问题 I'm trying to play some audio taken from an MPEG2 transport (.ts) file. I'm getting the audio stream via MediaExtractor, using readSampleData to copy samples to MediaCodec input buffers, then writing the MediaCodec output buffer to an AudioTrack. MediaExtractor indicates the audio MIME type as "audio/mp4a-latm". All this works wonderfully on a Nexus 7 2013 tablet. But it does not work at all on an inexpensive Neutab x7 tablet. The problem is that after a few samples, dequeueInputBuffer

AMediaExtractor setDataSource AMEDIA_ERROR_UNSUPPORTED error on Android Q

无人久伴 提交于 2019-12-24 04:54:11
问题 I am working with AMediaCodec and AMediaExtractor , all works fine on all devices(I hope:), but if I check the same code on Android Q (in my case Pixel 2XL) I got such error AMEDIA_ERROR_UNSUPPORTED . What I do bool NativeCodec::createStreamingMediaPlayer(const std::string &filename) { AMediaExtractor *ex = AMediaExtractor_new(); media_status_t err = AMediaExtractor_setDataSource(ex, filename.c_str());; <-- Here media status I got AMEDIA_ERROR_UNSUPPORTED if (err != AMEDIA_OK) { __android_log

How do I handle first output ByteBuffers of Android MediaCodec decoder?

六眼飞鱼酱① 提交于 2019-12-24 01:54:14
问题 I am trying to write an audio resampler using Android's MediaCodec suite. I am currently feeding an MP3 stereo audio file into a MediaExtractor which is then decoded by a MediaCodec. The sample rate of the source audio is 48000. What I don't understand is the first four output buffers I receive from the decoder: size 0, time 0 size 0, time 24000 size 4312, time 48000 size 4608, time 72000 size 4608, time 96000 etc. From this answer, this answer, and this article, I believe the first two