Setup Antmedia Video streaming with custom camera - android

I am new in video streaming related project! I Create a streaming server with ant media. Its working fine with opengl GLSurfaceView. But I want to replace this GLSurfaceView with custom cameraview. But I'm unable to figure out how to do it. I seen an opensource project on github: https://github.com/natario1/CameraView
I want use this camera view as stream source.
I'm done with below code:
LiveVideoBroadcaster.LocalBinder binder = (LiveVideoBroadcaster.LocalBinder) service;
if (mLiveVideoBroadcaster == null) {
mLiveVideoBroadcaster = binder.getService();
mLiveVideoBroadcaster.init(LiveVideoBroadcasterActivity.this, mGLView);
mLiveVideoBroadcaster.setAdaptiveStreaming(true);
}
mLiveVideoBroadcaster.openCamera(Camera.CameraInfo.CAMERA_FACING_FRONT);
Here mGLView is GLSurfaceView I want replace it with this custom camera view. Can anyone suggest from where can I start?

Related

How to get individual frames from a VLC MediaPlayer livestream on Android WITHOUT displaying the stream?

I am currently working on a project that requires me to stream video from an IP camera to an Android device via WiFi using RTSP and then do some image processing. I want to do this without displaying the video stream if possible. Currently, I am trying to do this using VLC for Android. My code is structured as follows:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayList<String> options = new ArrayList<>();
// Various options added.
mLibVLC = new LibVLC(getApplicationContext(), options);
mMediaPlayer = new MediaPlayer(mLibVLC);
videoLayout = findViewById(R.id.videoLayout); // This view is marked as INVISIBLE.
}
#Override
protected void onStart() {
super.onStart();
mMediaPlayer.attachViews(videoLayout, null, false, false);
Media media = new Media(mLibVLC, Uri.parse("<RTSP LINK>"));
// Set VLC media presets.
mMediaPlayer.setMedia(media);
media.release();
mMediaPlayer.play(); // Play the stream!
// Set callback to get each frame from MediaPlayer?
}
When videoLayout is marked as "visible", this works perfectly. I am also able to get Bitmaps from the view by performing a screen capture. When I mark the video layout as "invisible", far as I can tell I am still receiving frames (at least according to VLC's debug output) but I'm not sure how I can access them. Is there a way for me to directly render the MediaPlayer stream to a Bitmap? Or is there some other method I could use to get each new frame without rendering the view? Thanks for your help!
I figured this out after a lot of trial and error. The solution that worked best for me was to use FFMPEGFrameGrabber from JavaCV. I'm now able to read frame by frame from an RTSP stream.

How to save GLSurfaceView rendering to file?

I'm using VideoSurfaceView extends GLSurfaceView to render filtered video. I'm doing it buy changing the fragment shader according to my needs. Now I would like to save/render the video after the changes to a file of the same format(Ex. mp4 - h264) but couldn't find how to do it.
I am using this library - https://github.com/krazykira/VidEffects.
Any experts here?
I would try and use the MediaProjection API. Here is an Google sample for this api. Notice: this might not work on the new emulators.

Making video load faster in videoview

I play a video in a videoview from an URL...everything works fine and even the video plays
But the only problem is that the video takes almost 10 seconds to start playing which might be kind of annoying to the user
I have tried different URLs and its the same, the videos are 360p and 6sec long
Is it the default media player that is slow?
I have the stack overflow but could not find a suitable answer and ever searched for various 3 rd party videos libraries but could not find one
Even tried google's exoplayer library but the documentation is not that good in my view
Is there any solution how to overcome this problem?
my code
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String videeourl = "http://techslides.com/demos/sample-videos/small.3gp";
VideoView videoView = (FastVideoView)findViewById(R.id.video);
videoView.setMediaController(new MediaController(this));
videoView.setVideoPath(videeourl);
videoView.start();
}
}
Consider using Exoplayer. You can find the open source project here:
https://github.com/google/ExoPlayer
It uses Dynamic Adaptive Streaming over HTTP (DASH),breaks long content into HTTP segments.
You can follow this tutorial step-by-step to integrate ExoPlayer (ExoPlayer is the video player running in the Android YouTube app.) to your app, it's not that complicated as you thought.
https://codelabs.developers.google.com/codelabs/exoplayer-intro/index.html#0
By the way, there are a lot of good assignments in Google CodeLabs, you should check it out.

Rooted Android streaming video client for local ip camera without any delays

I have an ip camera and I want to include the video stream in an Android activity. To do that I included a VideoLayout with id video and I added this code to the onCreate method in the Activity.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView) findViewById(R.id.video);
Uri video = Uri.parse("rtsp://192.168.1.225/axis-media/media.amp");
videoView.setVideoURI(video);
videoView.start();
}
It works but there is an annoying delay of 10 seconds between the acquisition of the image from the camera and the displaying to the phone. I want the delay lesser than 2 seconds. I know the problem is related the fixed size of the buffer used for caching images during RTSP session. If I use vlc I can view the stream well by setting network-caching=0. Is there a way to do that in Android? The software destination is a ROOTED Android 4.0.3. Can I resolve by taking advantage of the root? I read that I can set the media.stagefright.cache-params of the build.prop file but I don't know if it is useful and how to set it..
Please help me! Thank you!

VideoView on Android, 2 issues

Trying to get a simple video clip playing in a loop. I got the video to play just fine. However, there are two problems I'm having.
If the user clicks the Home button, effectively hiding the app. Then they go back to it, the video is gone and doesn't reload.
Everything as far as initializing the video only takes place in the typical onCreate for the view that holds it. Where should I be calling the video from to start it to ensure that it always actually starts?
I can only get the device to find the video when pulling it from the web. I see in the logs that when I try to reference the clip from the RAW folder, it cannot find it.
VideoView myVideoView = (VideoView)findViewById(R.id.lighterView);
myVideoView.setVideoURI(Uri.parse("android.resource://com.android.AndroidVideoPlayer/"+R.raw.[videoclip]));
myVideoView.requestFocus();
myVideoView.start();
myVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer myVideoView) {
myVideoView.setLooping(true);
}
});
The above chunk of code works fine if I use a URL to my website. But locally, it cannot find the clip.
Instead of just load/play video in onStart() method I suggest you to look at some well written code about VideoView, because the best way to connect your video to your interface is manage your VideoView(that implements surfaceView) callBack.
You can find a good example at the following link;)
http://alvinalexander.com/java/jwarehouse/android/core/java/android/widget/VideoView.java.shtml

Categories

Resources