我正在开发一个实时流式Android应用程序。该应用程序将使用MediaRecorder在后台录制视频,我可以将其存储到SD卡。我正在尝试使用Wowza Media引擎来传输这段录制的视频,但视频没有传输。
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();
}
当我尝试使用RtspClient mClient传输此视频时出现此错误。请帮助我使用MediaRecoder录制的Wowza流式传输视频。 以下是Wowza http://www.androidhive.info/2014/06/android-streaming-live-camera-video-to-web-page/
的示例程序答案 0 :(得分:1)
出于好奇,我可以问你为什么要在手机上录音?我第一次想到如何从Android实现实时流式传输是使用Wowza GoCoder mobile encoding app从您的Android手机直播,或者使用Intel INDE Media Pack for Android内置的核心GoCoder技术构建您的流媒体应用程序(如果适用)你的情况)。如果您已经在使用Wowza Streaming Engine,它还可以从实时流中为您录制,可能节省手机处理,内存和电池。
-Chris