2
votes

I'm developing one live streaming android application. The app will record video in the background using MediaRecorder and I'm able to store that to sd card. I was trying Wowza Media engine to stream this recorded video but the video is not transferring.

surfaceView = new SurfaceView(this);
    LayoutParams layoutParams = new WindowManager.LayoutParams(1, 1,
            WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
            WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT);
    layoutParams.gravity = Gravity.LEFT | Gravity.TOP;
    windowManager.addView(surfaceView, layoutParams);
    surfaceView.getHolder().addCallback(this);

@Override
public void surfaceCreated(SurfaceHolder surfaceHolder) {

    Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
    int numberOfCameras = Camera.getNumberOfCameras();



    for (int i = 0; i < numberOfCameras; i++) {
        Camera.getCameraInfo(i, cameraInfo);
        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            camera = Camera.open(i);
        }

        if (cameraInfo.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
            // camera = Camera.open();
        }
    }

    mediaRecorder = new MediaRecorder();
    camera.unlock();

    mediaRecorder.setPreviewDisplay(surfaceHolder.getSurface());
    mediaRecorder.setCamera(camera);
    mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
    mediaRecorder.setProfile(CamcorderProfile
            .get(CamcorderProfile.QUALITY_HIGH));
    mediaRecorder.setOutputFile(Environment.getExternalStorageDirectory()
            + "/video_recording.mp4");

    mediaRecorder.setOrientationHint(270);
    try {
        mediaRecorder.prepare();
    } catch (Exception e) {
    }
    mediaRecorder.start();      

}

When i tried to stream this video using RtspClient mClient i got this error. Please help me to stream a video using Wowza that is been recording using the MediaRecoder. Here is a example program with Wowza http://www.androidhive.info/2014/06/android-streaming-live-camera-video-to-web-page/

1
I checked that code and they are using their own SurfaceView for recording the video. Here in my code i'm using MediaRecorder directly to record the video, Is there any possible way to set the output path to a live server..?LvN
There are a dozen of valid answers in the linked post, are you sure that none helps in your situation? For one, libstreaming does use MediaRecorder if it cannot use MediaCodec because the system API is too low, or due to some device-specific bugs.Alex Cohn
@AlexCohn Yeah, i fixed it by inflating that libstream custom SurfaceView on my Window in a background service. ThanksLvN

1 Answers

1
votes

Out of curiosity, may I ask why are you recording on the phone? My first thought on how to implement live streaming from Android was to stream live from your Android phone using the Wowza GoCoder mobile encoding app, or by building your streaming app using the core GoCoder technology built into the Intel INDE Media Pack for Android (if applicable for your situation). If you are already using Wowza Streaming Engine, it can also do the recording for you from the live stream, likely saving on phone processing, memory, and battery.

-Chris