2

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/

LvN
  • 701
  • 1
  • 6
  • 22
  • possible duplicate of [Streaming video from Android camera to server](http://stackoverflow.com/questions/2550847/streaming-video-from-android-camera-to-server) – Alex Cohn Sep 18 '14 at 18:34
  • 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 Sep 18 '14 at 18:39
  • 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 Sep 18 '14 at 21:10
  • 1
    @AlexCohn Yeah, i fixed it by inflating that libstream custom SurfaceView on my Window in a background service. Thanks – LvN Sep 19 '14 at 11:19

1 Answers1

1

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

  • While not an answer, this is a valuable comment; please consider editing this to be more answer-like. – Alex Cohn Sep 21 '14 at 08:44
  • As for the substance of your message, I understand that the poster was not looking for an app that would connect to a Wowza server, but rather prefer to do it from inside his/her app. – Alex Cohn Sep 21 '14 at 08:45
  • Regarding _saving on phone processing, memory, and battery_: to save the video on the local device in parallel to streaming it to a server, should not significantly effect memory or battery or CPU. – Alex Cohn Sep 21 '14 at 08:49