我正试图在Android中实现一个轻量级的RTSP服务器,以便将我的相机馈送实时流到VLC媒体播放器。为此,我使用流流库。我成功地在Android中导入了库,并成功地为服务器端编译和运行了骨架码。不幸的是,这个程序并没有像预期的那样工作。相机预览无法加载,我无法在VLC媒体播放器中读取MRL。以前有没有人面对过这个问题?任何帮助都将不胜感激!提前谢谢。以下是我迄今尝试过的:
public class MainActivity extends Activity {
private final static String TAG = "MainActivity";
private SurfaceView mSurfaceView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
setContentView(R.layout.activity_main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
mSurfaceView = (SurfaceView) findViewById(R.id.surface);
// Sets the port of the RTSP server to 1234
Editor editor = PreferenceManager.getDefaultSharedPreferences(this).edit();
editor.putString(RtspServer.KEY_PORT, String.valueOf(1234));
editor.commit();
// Configures the SessionBuilder
SessionBuilder.getInstance()
.setSurfaceView(mSurfaceView)
.setPreviewOrientation(90)
.setContext(getApplicationContext())
.setAudioEncoder(SessionBuilder.AUDIO_NONE)
.setVideoEncoder(SessionBuilder.VIDEO_H264);
// Starts the RTSP server
this.startService(new Intent(this,RtspServer.class));
}
}我试图访问MRL: rtsp://192.168.2.3:1234/
发布于 2016-09-26 18:07:41
你正在尝试的代码是好的。URL需要有特定的格式,
VLC播放器中的URL应该是rtsp://phone_local_ip:1234?h264=200-20-320-240
200 = buf = 20 = fps,320 =宽度,240 =高度
https://stackoverflow.com/questions/33638321
复制相似问题