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 searching around for a sample code on internet and all i can find are the references which are based on Java MediaCodec class.
If anyone has any sample reference code or any links to the C++ based asynchronous usage of MediaCodec to render a video file, that would be great.
Any guidance on this would also be great on this.
An example of converting the ExtractDecodeEditEncodeMuxTest example from synchronous mode to asynchronous mode is available at https://github.com/mstorsjo/android-decodeencodetest. See the commit history for all the steps leading up to this.
This isn't C++ and it isn't for rendering, but it covers a few of the essential aspects at least.
Related
We are trying to integrate Oboe and the library size seems to be big.We dont need any processing like resampling ,format conversion .This we do in app and would like to know if its possible to significantly reduce library size with our only requirement using Oboe being for Audio IO.
The source to configuring streams with flow graphs where lot of processing code seems to exist.Is there any easy way to take this processing code and use only Audio IO part.
I am building an application in which I need to trim videos. It is possible to do this using ffmpeg, but I can't use it because it uses the gpl license.
I tried using mediaCodec but can't use the codes I found.
How can i trim videos on android?
I had to develop trim functionality into my app a few months back and found that FFMPEG is very heavy and wasn't as accurate as MediaCodec.
None of the examples helped me but as I was developing in Kotlin I had to rewrite it anyway.
Here is the breakdown of how to use MediaCodec:
Pass the file to your mediacodec class
Extract the video from a file
Create your buffer size
Seek to where you want to file to be trimmed from or to
Mux your audio and video together
We tried to find a way to do the start and finish times together but we ended up just duplicating the clip first and passing both in with a start and and end time.
You'll need to post your code and show where you're having the issue with MediaCodec for people to help you.
I am Building An app for on line streaming,using MediaPayer to stream videos,
player.setDataSource(this, Uri.parse(getLink()));
but his seems rather slow ,is there more efficient way to stream videos ,please guide
thanx in advance
is there more efficient way to stream videos ?
You could try using the VideoView class:
https://developer.android.com/reference/android/widget/VideoView.html
Displays a video file. The VideoView class can load images from
various sources (such as resources or content providers), takes care
of computing its measurement from the video so that it can be used in
any layout manager, and provides various display options such as
scaling and tinting.
or if you are willing to write some boiler plate code (mostly using dependency injection) you could try ExoPlayer.
https://developer.android.com/guide/topics/media/exoplayer.html
There is some excellent sample code in GitHub for ExoPlayer as well to get you started.
I'd like to write an app that merges multiple images into a movie on Android. JMF has a basic implementation (JpegImagesToMovie). But, JMF isn't supported on Dalvik.
Is there an alternative library that I can use for this ? Or if there is no library available, does anyone have any pointers for what I need to research to implement myself.
Rgds, Kevin.
I'm not aware of any pure-Java video encoders, and the built-in video encoder in Android appears to be limited to capturing video from the camera alone, rather than a custom input source.
You could look at writing a multi-part JPEG (quite rare but well supported) writer, or even an MJPEG (used by many digicams) encoder.
Short version: What is the best way to get data encoded in an MP3 (and ideally in an
AAC/Ogg/WMA) into a Java array or ByteBuffer that I can then
manipulate?
I'm putting together a program that has slowing down and speeding up
sound files as one of its features. This works fine for WAV files,
which are a header plus the exact binary data that needs to be sent to
the speaker, and now I need to implement it for MP3 (ideally, this
would also support AAC, Ogg, and WMA, but since those are less popular
formats this is not required). Android does not expose an interface
to decode the MP3 without playing it, so I need to create that
interface.
Three options present themselves, though I'm open to others:
1) Write my own decoder. I already have a functional frame detector
that I was hoping to use for option (3), and now should only need to
implement the Huffman decoding tables.
2) Use JLayer, or an equivalent Java library, to handle the
decoding. I'm not entirely clear on what the license ramifications
are here.
3) Connect to the libmedia library/MediaPlayerService. This is what
SoundPool does, and the amount of use of that service make me believe
that while it's officially unstable, that implementation isn't going
anywhere. This means writing JNI code to connect to the service, but
I'm finding that that's a deep rabbit hole. At the surface, I'm
having trouble with the sp<> template.
I did that with libmad and the NDK. JLayer is way to slow and the media framework is a moving target. You can find info and source code at http://apistudios.com/hosted/marzec/badlogic/wordpress/?p=231
I have not tried it, but mp3transform is LGPL.