what is the most efficient way to stream videos in android app - android

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.

Related

How to trim a video without using ffmpeg on Android?

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.

Decoding a video on the fly in exoplayer

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!

android -What is the best way to play video in my application

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

create mjpeg video from pictures in Android

I have a small application that stream pictures from a device using android. I'm able to take pictures and save into sdcard and now I have been willing to do some video recording with that. I have done it using IOS: I save the pictures into an array and for each pictures, I create a mjpeg video with these combined pictures.
I have thought of using pure java to do so, but most of the import libraries cannot be supported in Android.
I have tried to use this: https://github.com/lessthanoptimal/BoofCV/blob/master/main/io/src/boofcv/io/video/CreateMJpeg.java
But it cannot be played for some unknown reason.
I'm out of ideas. Please help me.
Thank you
You can use MJPEGGenerator.java to create an AVI from a set of jpg images
This is example of using MJPEGGenerator in russian language. Use translate.google.com to understand.

Android - Merge image files to a movie (but not using JMF)

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.

Categories

Resources