E/MediaRecorder:启动失败:-38
E/MediaRecorder: start failed: -38
这是我的代码。
基本上,我正在尝试使用 rtsp 将 android 屏幕流式传输到 vlc 媒体播放器,但我设法以某种方式完美地流式传输视频,但没有播放音频。
我正在使用 AMRNB 编码方法在本地套接字上发送流。
我可以通过使用日志看到有音轨,它也在发送,但不知道为什么它没有播放。
mMediaRecorder.setAudioSource (mAudioSource);
mMediaRecorder.setOutputFormat (mOutputFormat);
mMediaRecorder.setAudioEncoder (mAudioEncoder);
mMediaRecorder.setAudioChannels (1);
mMediaRecorder.setAudioSamplingRate (mQuality.samplingRate);
mMediaRecorder.setAudioEncodingBitRate (mQuality.bitRate);
mMediaRecorder.setOutputFile (mSender.getFileDescriptor());
mMediaRecorder.prepare();
mMediaRecorder.start();
Log.d(" audio ", mMediaRecorder.toString ());
try {
// mReceiver.getInputStream contains the data from the camera
// the mPacketizer encapsulates this stream in an RTP stream and send it over the network
mPacketizer.setDestination (mDestination, mRtpPort, mRtcpPort);
mPacketizer.setInputStream (mReceiver.getInputStream ( ));
mPacketizer.start ( );
Log.d(" packetizer ", mPacketizer.toString ());
mStreaming = true;
} catch (IOException e) {
stop ( );
throw new IOException ("Something happened with the local sockets :/ Start failed !");
}
这是我的Logcat
E/RtspServer: SETUP 192.168.1.86:25670/trackID=0
D/dest: 192.168.1.89
V/MediaStream: Requested audio with 32kbps at 8kHz
D/MediaRecorder: Constructor MediaRecorder
I/MediaRecorderJNI: setup
I/MediaRecorderJNI: setAudioSource(1)
I/MediaRecorderJNI: setAudioEncoder(2)
setParameter()
I/MediaRecorderJNI: setParameter()
I/MediaRecorderJNI: setParameter()
I/MediaRecorderJNI: setOutputFile
prepare
I/MediaRecorderJNI: start
E/MediaRecorder: start failed: -38
D/RtspServer: RTSP/1.0 200 OK
Server: MajorKernelPanic RTSP Server
Cseq: 4
Content-Length: 0
Transport: RTP/AVP/UDP;unicast;destination=192.168.1.89;client_port=5010-5011;server_port=33462-44704;ssrc=f6dc348c;mode=play
Session: 1185d20035702ca
Cache-Control: no-cache
E/RtspServer: SETUP 192.168.1.86:25670/trackID=1
D/dest: 192.168.1.89
D/H264Packetizer: H264 packetizer started !
header is 0 0 0 1 33 ts = 76657985454000 nalu len = 24
D/RtspServer: RTSP/1.0 200 OK
Server: MajorKernelPanic RTSP Server
Cseq: 5
Content-Length: 0
Transport: RTP/AVP/UDP;unicast;destination=192.168.1.89;client_port=36882-36883;server_port=51731-41042;ssrc=e0e9342d;mode=play
Session: 1185d20035702ca
Cache-Control: no-cache
D/H264Packetizer: header is -128 0 0 0 1 ts = 76658035880000 nalu len = 1333
D/CompatibilityChangeReporter: Compat change id reported: 147798919; UID 10362; state: ENABLED
已更新
在处理这个问题时,我发现我正在 android Lolipop 上测试我的项目,并且无法直接在 LocalSockets 上读写。您必须使用 ParcelFileDiscriptor 来传输音频。
这是我的代码。 基本上,我正在尝试使用 rtsp 将 android 屏幕流式传输到 vlc 媒体播放器,但我设法以某种方式完美地流式传输视频,但没有播放音频。 我正在使用 AMRNB 编码方法在本地套接字上发送流。 我可以通过使用日志看到有音轨,它也在发送,但不知道为什么它没有播放。
mMediaRecorder.setAudioSource (mAudioSource);
mMediaRecorder.setOutputFormat (mOutputFormat);
mMediaRecorder.setAudioEncoder (mAudioEncoder);
mMediaRecorder.setAudioChannels (1);
mMediaRecorder.setAudioSamplingRate (mQuality.samplingRate);
mMediaRecorder.setAudioEncodingBitRate (mQuality.bitRate);
mMediaRecorder.setOutputFile (mSender.getFileDescriptor());
mMediaRecorder.prepare();
mMediaRecorder.start();
Log.d(" audio ", mMediaRecorder.toString ());
try {
// mReceiver.getInputStream contains the data from the camera
// the mPacketizer encapsulates this stream in an RTP stream and send it over the network
mPacketizer.setDestination (mDestination, mRtpPort, mRtcpPort);
mPacketizer.setInputStream (mReceiver.getInputStream ( ));
mPacketizer.start ( );
Log.d(" packetizer ", mPacketizer.toString ());
mStreaming = true;
} catch (IOException e) {
stop ( );
throw new IOException ("Something happened with the local sockets :/ Start failed !");
}
这是我的Logcat
E/RtspServer: SETUP 192.168.1.86:25670/trackID=0
D/dest: 192.168.1.89
V/MediaStream: Requested audio with 32kbps at 8kHz
D/MediaRecorder: Constructor MediaRecorder
I/MediaRecorderJNI: setup
I/MediaRecorderJNI: setAudioSource(1)
I/MediaRecorderJNI: setAudioEncoder(2)
setParameter()
I/MediaRecorderJNI: setParameter()
I/MediaRecorderJNI: setParameter()
I/MediaRecorderJNI: setOutputFile
prepare
I/MediaRecorderJNI: start
E/MediaRecorder: start failed: -38
D/RtspServer: RTSP/1.0 200 OK
Server: MajorKernelPanic RTSP Server
Cseq: 4
Content-Length: 0
Transport: RTP/AVP/UDP;unicast;destination=192.168.1.89;client_port=5010-5011;server_port=33462-44704;ssrc=f6dc348c;mode=play
Session: 1185d20035702ca
Cache-Control: no-cache
E/RtspServer: SETUP 192.168.1.86:25670/trackID=1
D/dest: 192.168.1.89
D/H264Packetizer: H264 packetizer started !
header is 0 0 0 1 33 ts = 76657985454000 nalu len = 24
D/RtspServer: RTSP/1.0 200 OK
Server: MajorKernelPanic RTSP Server
Cseq: 5
Content-Length: 0
Transport: RTP/AVP/UDP;unicast;destination=192.168.1.89;client_port=36882-36883;server_port=51731-41042;ssrc=e0e9342d;mode=play
Session: 1185d20035702ca
Cache-Control: no-cache
D/H264Packetizer: header is -128 0 0 0 1 ts = 76658035880000 nalu len = 1333
D/CompatibilityChangeReporter: Compat change id reported: 147798919; UID 10362; state: ENABLED
已更新
在处理这个问题时,我发现我正在 android Lolipop 上测试我的项目,并且无法直接在 LocalSockets 上读写。您必须使用 ParcelFileDiscriptor 来传输音频。