android-decodeencodetest | convert ExtractDecodeEditEncodeMuxTest to asynchronous mode
kandi X-RAY | android-decodeencodetest Summary
kandi X-RAY | android-decodeencodetest Summary
Example on how to convert ExtractDecodeEditEncodeMuxTest to asynchronous mode
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of android-decodeencodetest
android-decodeencodetest Key Features
android-decodeencodetest Examples and Code Snippets
Community Discussions
Trending Discussions on android-decodeencodetest
QUESTION
I am using MediaCodec
in asynchronous mode to transcode a video based on the example by mstorsjo. With some video files I am getting IllegalStateException
's thrown when I call either MediaExtractor.advance()
or MediaExtractor.getSampleTime()
. E.g. in my audio decoder:
ANSWER
Answered 2018-Feb-21 at 11:13My best solution so far is to just wrap everything in a try catch
block. I use a utility class that extends MediaCodec.Callback
:
QUESTION
I want to be able to write a bitmap to a video using MediaCodec. I want the video to be e.g. 3 seconds long and 30 fps. I am targeting Android API 21.
I have a class that does the drawing:
...ANSWER
Answered 2018-Feb-06 at 12:31Efficiency wise, this drawing of the input frame probably is as efficient as it will get. Each time you submit a frame to the encoder, you can't really assume anything about the input surface buffer content (I think), so you need to copy the content to be encoded into it somehow, and this does pretty much it.
If you skip drawing, you need to keep in mind that the surface you're drawing into isn't just a single buffer, but a set of a number of buffers (usually 4-10 buffers or so). When using the direct buffer access mode of the encoder, the encoder will tell you exactly which one of the buffers out of the pool it gave you to fill, and in such cases, you might have better luck with skipping drawing in the case if you've already filled the buffer before (and hoping that the encoder hasn't invalidated the contents).
With surface input, you don't get to know which buffer you got to write into. In that case, you could e.g. try just doing the drawing the first N times. I don't think you can get the actual number of buffers though - you could try calling the deprecated getInputBuffers() method, but I don't think it's possible to use it in combination with surface input.
However, about performance, the absolutely biggest issue and reason for your (lack of) performance is that you're doing everything synchronously. You said
At the start of the processing, and then every time I successfully mux a frame thereafter, I call
Hardware encoders generally have a bit of latency, and the time it takes to encode a single frame from start to finish is longer than the average time per frame, if you start encoding more than one at a time.
Assuming you're using MediaCodec in async mode, I would suggest to just serially do the encoding of all the 90 frames in one thread, and write output packets to the muxer when you get them in the callback. That should keep the encoder pipeline busy. (Once the input buffers to the encoder are exhausted, the inputSurface methods will block until the encoder has completed a frame and freed up another one of the input buffers.) You might also want to buffer the output packets in a queue and write them asynchronously to the muxer (I remember reading about cases where MediaMuxer occasionally can block longer than you'd like).
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install android-decodeencodetest
You can use android-decodeencodetest like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the android-decodeencodetest component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page