android-mediacodec

If is it possible to get BGR from MediaCodec?

我与影子孤独终老i 提交于 2019-12-11 15:45:54
问题 As far as I know, MediaCodec return output buffer of image in YUV420 and then you can process with it as you like to... But in my case I need to convert YUV420 in BGR , it is quite expensive conversion. So, question is if it is possible immediately (without conversion) get BGR from MediaCodec ? My code now uint8_t *buf = AMediaCodec_getOutputBuffer(m_data.codec, static_cast<size_t>(status), /*bufsize*/nullptr); cv::Mat YUVframe(cv::Size(m_frameSize.width, static_cast<int>(m_frameSize.height *

NdkMediaCodec: couldn't get output / input buffers

限于喜欢 提交于 2019-12-11 15:28:42
问题 I am using native codec to read .mp4 file... My application flow: I have 2 buttons when I click on first button I am starting to read one .mp4 file, when I click second button I am starting to read another .mp4 file So, problems came when I am clicking on the buttons 1 and 2 in one second delay between them in order to check app behaviour when I am switching the video from one to another... And sometimes I get crash with such log / E/NdkMediaCodec: sf error code: -38 / E/NdkMediaCodec: sf

How to get decode format from MediaCodec?

老子叫甜甜 提交于 2019-12-11 14:25:42
问题 I am working with MediaCodec I am using it for decode .mp4 video MediaCodec decode a video to YUV format, but I need to get RGBA All is ok, but I found out that there is a few possible formats like YUV420 , YUV422 and so on... So, as far as I understand to make conversion I need to know exactly which conversion to apply YUV420_to_RGBA or YUV422_to_RGBA or something else... So, question is - how using MediaCodec get know about decoding format? Feel free to ask. EDIT I found out that this way I

support full swing android media decoder?

青春壹個敷衍的年華 提交于 2019-12-10 11:54:41
问题 When I decode a full swing video using Android MediaCodec class, the output is always in studio swing? am I missing a header in the video file? I know after Android 24, I can use MediaFormat class to set COLOR_RANGE_FULL ? Any help on this? seems like even setting MediaFormat.setInteger(MediaFormat.KEY_COLOR_RANGE, MediaFormat.COLOR_RANGE_FULL); Also doesn't help on android 24. 回答1: I talked to engineers from Android team at Google, and they mentioned this part of the code should be

How to adjust play speed of video on android? [closed]

╄→гoц情女王★ 提交于 2019-12-07 11:14:35
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last year . I need to implement a requriment of adjust play speed when playing a video, how can I do that using Android API (MediaPlayer) or other 3rd-party library? I google it, and no any idea by far. Any suggestions welcome, thank you. 回答1: Media player does not provide what you want. You

Recording video using MediaCodec with Camera2 API

醉酒当歌 提交于 2019-12-06 22:11:40
问题 I am trying to use MediaCodec to record raw frames from ImageReader in onImageAvailable callback but unable to write a working code. Most of the examples are using Camera 1 API or MediaRecorder. My aim is to capture individual frames process it and create an mp4 out of it Raw YUV frames @Override public void onImageAvailable(ImageReader reader) { Image i = reader.acquireLatestImage(); processImage(i); i.close(); Log.d("hehe", "onImageAvailable"); } }; MediaCodec MediaCodec codec = MediaCodec

Recording video using MediaCodec with Camera2 API

家住魔仙堡 提交于 2019-12-05 02:23:20
I am trying to use MediaCodec to record raw frames from ImageReader in onImageAvailable callback but unable to write a working code. Most of the examples are using Camera 1 API or MediaRecorder. My aim is to capture individual frames process it and create an mp4 out of it Raw YUV frames @Override public void onImageAvailable(ImageReader reader) { Image i = reader.acquireLatestImage(); processImage(i); i.close(); Log.d("hehe", "onImageAvailable"); } }; MediaCodec MediaCodec codec = MediaCodec.createByCodecName(name); MediaFormat mOutputFormat; // member variable codec.setCallback(new MediaCodec

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

Using MediaCodec asynchronously to decode and render a Video File

谁都会走 提交于 2019-11-29 18:25:45
Recently started toying around with the Android Media Codec class to render the video frames from a Native C++ application. Was able to successfully decode and render both audio and video streams using Android MediaCodec class using synchronous approach[queueInputBuffer and deququeInputBuffer]. Android has a good reference example of how to do it in Native C++ Application. Ex : SimplePlayer.cpp Now i have started with the implementation of asynchronous approach using callbacks and feed the input streams to codec in those callbacks[OnInputBufferAvailable/ OnOutPutBufferAvailable]. I was

How to get frame by frame from MP4? (MediaCodec)

你。 提交于 2019-11-29 15:40:58
Actually I am working with OpenGL and I would like to put all my textures in MP4 in order to compress them. Then I need to get it from MP4 on my Android I need somehow decode MP4 and get frame by frame by request. I found this MediaCodec https://developer.android.com/reference/android/media/MediaCodec and this MediaMetadataRetriever https://developer.android.com/reference/android/media/MediaMetadataRetriever But I did not see approach how to request frame by frame... If there is someone who worked with MP4, please give me a way where to go. P.S. I am working with native way (JNI), so does not