0

I'm trying to stream the part of my desktop to my Android device.

I create stream by means of VLC media player. I construct H.264 stream with 2048 Kb/sec and 30 fps, pack it into mp4/mov container and publish it like this: rtsp://[my-ip]:[port]/stream. It is important that I don't wanna simply stream the file from the media server, but I want to make live translation of my desktop available via stream with properties, described above.

According to Android documentation from here http://developer.android.com/guide/appendix/media-formats.html it must be possible to consume H.264 video over RTSP stream on Android device (my device runs on 4.2).

But my VideoView widget says that video not found, while I can actually see my stream from another PC by means of VLC player installed here. So how can I achieve my initial goal?

Here is my Android application code:

main_layout.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <VideoView
        android:id="@+id/videoRectangle"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="100dp" />

    <Button
        android:id="@+id/connectToVideoServerButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/videoRectangle"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="10dp"
        android:text="Присоединиться" />

    <EditText
        android:id="@+id/streamServerAddress"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_alignBaseline="@+id/connectToVideoServerButton"
        android:layout_alignBottom="@+id/connectToVideoServerButton"
        android:layout_marginLeft="30dp"
        android:layout_toRightOf="@+id/connectToVideoServerButton"
        android:ems="10"
        android:hint=""
        android:text="" >

        <requestFocus />
    </EditText>

</RelativeLayout>

MainActivity.java:

package com.example.videostreamerclient;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.VideoView;

public class MainActivity extends Activity {

    private VideoView videoView;
    private Button videoServerConnectBtn;
    private EditText streamServerAddress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        videoView = (VideoView) findViewById(R.id.videoRectangle);
        streamServerAddress = (EditText) findViewById(R.id.streamServerAddress);
        videoServerConnectBtn = (Button) findViewById(R.id.connectToVideoServerButton);

        videoServerConnectBtn.setOnClickListener(videoServerConnectBtnClicked);     
    }

    private View.OnClickListener videoServerConnectBtnClicked = new View.OnClickListener() {
        @Override
        public void onClick(View v){
            if ( streamServerAddress.getText().toString() != "" )
            {
                videoView.setVideoPath( streamServerAddress.getText().toString() );
                videoView.start();
            }           
        }
    };  

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

}
GuardianX
  • 515
  • 11
  • 29
  • Try to replace `videoView.setVideoPath()` with `videoView.setVideoURI()`. – Eugene May 24 '13 at 08:28
  • @Eugene I already tried it. Still doesn't work. – GuardianX May 24 '13 at 08:35
  • Does it work if you are trying to play video from another source. Let's say [this one](http://www.wowza.com/html/mobile.html) – Eugene May 24 '13 at 08:40
  • @Eugene yes both of those video streams work. So how can I configure my stream properly? Note also that it's not hosted file like those two, it's live streaming from desktop. Thx. – GuardianX May 24 '13 at 08:59
  • I'm not familiar with vlc server. Definitely you have to prepare RTSP url properly. Also check that appropriate ports are open on the your streaming server. Take a look at these links: [vlc streaming](http://www.videolan.org/doc/streaming-howto/en/ch04.html), [similar issue](http://stackoverflow.com/questions/15837390/vlc-rtsp-live-stream-to-android) – Eugene May 24 '13 at 09:23
  • @Eugene well ye, that's why I am asking my question. My stream uses proper codecs defined in corresponding google documents. But my stream can not be played on Android. I can play it in any other stream-playing software just fine. I can play it even in browser. I cannot produce single file like in all links above because it is live desktop streaming, so my url looks like http://address:port/stream, or rtsp://address:port/stream. There is no 3gp, or mov file extension exists in my url address. – GuardianX May 24 '13 at 10:30

0 Answers0