自分の画面のコンテンツをrtmpサーバーにストリーミングしようとしていますが、これを行う最も簡単な方法はffmpegを使用することです。Android - MediaRecorderがffmpegのストリームに出力する
だから、ここで私がこれまで持っているものです。ここで
try {
Socket socket = new Socket(url, port);
ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.fromSocket(socket);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mMediaRecorder.setOutputFile(fileDescriptor.getFileDescriptor());
mMediaRecorder.setVideoSize(DISPLAY_WIDTH, DISPLAY_HEIGHT);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoEncodingBitRate(512 * 1000);
mMediaRecorder.setVideoFrameRate(30);
int rotation = getWindowManager().getDefaultDisplay().getRotation();
int orientation = ORIENTATIONS.get(rotation + 90);
mMediaRecorder.setOrientationHint(orientation);
mMediaRecorder.prepare();
} catch (IOException e) {
e.printStackTrace();
}
、重要な部分は、私がAsynctask内でこれを置くとき、私はそれを送信しようとすることができ、そう
Socket socket = new Socket(url, port);
ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.fromSocket(socket);
mMediaRecorder.setOutputFile(fileDescriptor.getFileDescriptor());
です何かが、私はそうUnknownHostException
java.net.UnknownHostException: Unable to resolve host "rtmps://rtmp-api....": No address associated with hostname
を取得し、私は私がすべきことを言われてきました代わりにffmpegを使用してください。しかし、元のストリームをMediaRecorderから取得してffmpegに渡す方法はわかりません。
私が正しく理解していれば、ffmpegのは次のように使用する:
だから、-i original_stream rtmps://rtmp-api...
、どのように私は(ない保存されたファイルで)ストリーミング用のffmpegで使用できる形式でMediaRecorderの出力内容を得ることができます。
ありがとうございます!
感謝。それはいくつかの約束を示していますが、私はこのコードを使って、本当に必要なものがあるかどうかを確認する必要があります。 私はあなたに最新の情報を提供します。 – TooManyEduardos