I'm using the Android ExoPlayer to play a video, but I want to implement some custom encoding mechanism.
The idea is to change certain bytes on the video file, so that it's not playable from standard players. And then in ExoPlayer perform the decoding on the fly (without actually modifying the stored file).
How could I do such a thing - using a custom DataSource? Any tips on this would be much appreciated!
Related
How can I stream video from byteArray
fun streamVideoListener(frame: ByteArray){
// receiving H.264 frames every 100ms.
}
I tried FFmpeg library. merged 100 frames and make few seconds video and add it to ExoPlayer playlist. but performance is not good at all.
I also tried NanoHttpd library. I can send a simple .mp4 video file and play it with vlc or MxPlayer, but don't know how to stream a growing video file (without refreshing page)
You'll need to implement a custom DataSource implementing the com.google.android.exoplayer.upstream.DataSource interface or extend the BaseDataSource from exoplayer library. Store the byte array and in the read method provide the stored byte array. You can see usage in the RtmpDataSource class of the exoplayer library
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've encounter this problem many times , the problem is that I've a videoView in my application but it couldn't play lots of different formats and video files.
for example , if I want to open a mp4 file, I should ask my users to convert the video to a H.264 format and then upload the file and it's very hard.
I'm looking for a better way to play various formats of videos .
Does any one no any way to do so ? have can I do that ?
If you're willing to use a third party library, FFmpegMediaPlayer is a is a reimplementation of Android's MediaPlayer class based on FFmpeg. It adds support for additional formats and protocols not provided by Android's MediaPlayer class. It is licensed under LGPLv2.1.
In android, .mp4 extension is the most common video format which is compatible for the default playback.
Objective:
Implemention of VideoView for the playback of Videos.
Usage of MediaController for the playback controls.
SurfaceView which will hold the playback of Videos.
Containers that are used for playing videos:
VideoView
MediaController
SurfaceView
DisplayMetrics
Read more: http://mrbool.com/how-to-play-video-formats-in-android-using-videoview/28299#ixzz3uUX2Bew0
Or for getting best answer , you need to see this link.
Best way to play a Video file?
I suggest you to try out ExoPlayer. It has really nice features and documentations. Try this codelabs tutorial. https://codelabs.developers.google.com/codelabs/exoplayer-intro/#0
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.