[FFmpeg-user] Recipe to stream to Android

Joe Kreidler joek at optimaldesignco.com
Mon Jan 21 17:03:52 CET 2013


Fing

I have not searched for other free apps that are known to easily play RTSP
streams on Android. Sorry.

With respect to my working solution recipe, I am glad to share. There are 4
parts to this.

1 - a local LAN connection between the stream server and the Android
client. I used my local WiFi.
2 - ffmpeg to transcode the content. For the content, I used a local video
file that I had captured on an Android device and copied to my server
machine.
3 - ffserver to stream the content
4 - a test Android app.

For #2, the command I used was:
   ffmpeg -i test.mp4 http://10.10.10.143:8090/feed1.ffm

For #3, here is my complete ffserver configuration file.

Port 8090
BindAddress 0.0.0.0
RTSPPort 7654
RTSPBindAddress 0.0.0.0
MaxClients 4
MaxBandwidth 10000
NoDaemon

<Feed feed1.ffm>
File /tmp/feed1.ffm
FileMaxSize 20M
ACL allow 10.10.10.0 10.10.10.255
</Feed>

<Stream mystream.sdp>
Feed feed1.ffm
Format rtp
VideoCodec libx264
VideoSize 640x480
VideoQMin 1
VideoQMax 20
AVOptionVideo flags +global_header
NoAudio
</Stream>

<Stream status.html>
Format status
ACL allow 10.10.10.0 10.10.10.255
</Stream>



For #4, here is my Android test app. It consists of a layout file and a
single activity.

The layout file name is "activity_main.xml" and its contents are:

<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"
    tools:context=".MainActivity" >

    <VideoView android:id="@+id/VideoView"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
    />

</RelativeLayout>

The activity file name is "MainActivity.java" and its contents are:

package com.optimaldesignco.stream;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.net.Uri;
import android.widget.MediaController;
import android.widget.VideoView;


public class MainActivity extends Activity
{

  VideoView videoView;

  @Override
  protected void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);

    videoView = null;

    setContentView(R.layout.activity_main);

    videoView =(VideoView)findViewById(R.id.VideoView);
    MediaController mediaController= new MediaController(this);
    mediaController.setAnchorView(videoView);

    // Uri uri =
Uri.parse("rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov");
    Uri uri = Uri.parse("rtsp://10.10.10.143:7654/mystream.sdp");

    videoView.setMediaController(mediaController);
    videoView.setVideoURI(uri);
    videoView.requestFocus();
    videoView.start();
 }
}

Joe


On Fri, Jan 18, 2013 at 1:18 PM, Fing Cmo <fingcmo at gmail.com> wrote:

> Thanks for coming back with the solution.
> Can you create a complete tutorial of a working example?
> That would help a lot!
>
> Besides your Android app, what other free Android app is known to
> easily play an RTSP stream like the example you gave:
> rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov
>
> Fing.
> ...................
>
> On Fri, Jan 18, 2013 at 9:32 AM, Joe Kreidler <joek at optimaldesignco.com
> >wrote:
>
> > I found my problem and the solution was very easy. All I had to do was
> add
> > the
> > following line to my ffserver configuration file.
> >
> > AVOptionVideo flags +global_header
> >
> > The addition of the global_header flag forced ffmpeg to include the
> > sprop-parameter-sets
> > and the profile-level-id attributes in the SDP. With this change, I am
> able
> > to receive RTSP/RTP content on Android.
> >
> >
> > Joe
> >
> >
> >
> >
> > On Thu, Jan 10, 2013 at 10:14 AM, Joe Kreidler <joek at optimaldesignco.com
> > >wrote:
> >
> > > I asked this question on the ffserver mail list, but there has not been
> > > any responses. I'm trying the ffmpeg list since this list is more
> active
> > > and I am not sure if my problem is in ffserver or ffmpeg.
> > >
> > > I am trying to stream H264 video using ffmpeg and ffserver on a Ubuntu
> > > 12.04LTS desktop to an Android tablet running a small test client app
> > > on Ice Cream Sandwich v 4.0.4. Note, I am not using ffmpeg or ffserver
> > > on Android. I know my test client app is working properly because I can
> > > successfully stream the following H.264 content.
> > > rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov
> > >
> > > I know that the problem is that ffserver is generating the SDP for the
> > > video media like this:
> > >
> > > m=video 0 RTP/AVP 96
> > > b=AS:128
> > > a=rtpmap:96 H264/90000
> > > a=fmtp:96 packetization-mode=1
> > > a=control:streamid=0
> > >
> > > The format parameter line (a=fmtp) is missing the
> "sprop-parameter-sets"
> > > and "profile-level-id" parameters and without these parameters, Android
> > > does not accept the RTP data.  A valid line looks like this:
> > >
> > > a=fmtp:96 packetization-mode=1;
> > > sprop-parameter-sets=Z0LAHukBQHsg,aM4G4g==; profile-level-id=42C01E
> > >
> > > My ffmpeg and ffserver configuration files are included below. If
> > > someone has successfully streamed H.264 content to an Android tablet,
> > > can you share you configuration me with?
> > >
> > > Thank you in advance,
> > >
> > > Joe
> > >
> > >
> > > I captured a video on the Android device and played it back just
> > > to verify that I had a good video file. I then transferred the file to
> > > my Ubuntu desktop. I send the video content to ffserver using the
> "copy"
> > > codec, in other words, no transcoding of the content at all.
> > >
> > > ffmpeg -i test.mp4 -c copy http://10.10.10.143:8090/feed1.ffm
> > >
> > > Port 8090
> > > BindAddress 0.0.0.0
> > > RTSPPort 7654
> > > RTSPBindAddress 0.0.0.0
> > > MaxClients 4
> > > MaxBandwidth 10000
> > > NoDaemon
> > >
> > > <Feed feed1.ffm>
> > > File /tmp/feed1.ffm
> > > FileMaxSize 20M
> > > ACL allow 10.10.10.0 10.10.10.255
> > > </Feed>
> > >
> > > <Stream 4Di.sdp>
> > > Feed feed1.ffm
> > > Format rtp
> > > VideoSize 640x480
> > > VideoQMin 1
> > > VideoQMax 2
> > > NoAudio
> > > </Stream>
> > >
> > > <Stream status.html>
> > > Format status
> > > ACL allow 10.10.10.0 10.10.10.255
> > > </Stream>
> > >
> > >
> >
> >
> > --
> >
> > Joe Kreidler
> > Lead Software Engineer
> > Optimal Design
> >
> > 601 W. Campus Dr., Suite B3
> >
> > Arlington Heights, IL  60004
> >
> > Office: 847-818-1000 x 38
> >
> > Fax: 847-483-1461
> > Mobile: 312-615-6431
> >
> >  www.OptimalDesignCo.com <http://www.optimaldesignco.com/>
> >
> >
> > Follow Optimal Design on
> > Linkedin<http://www.linkedin.com/company/optimal-design>
> > , Twitter <https://twitter.com/#!/OptimalDesignCo> and
> > Facebook<http://www.facebook.com/pages/Optimal-Design/217642344936481>
> > _______________________________________________
> > ffmpeg-user mailing list
> > ffmpeg-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/ffmpeg-user
> >
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>



-- 

Joe Kreidler
Lead Software Engineer
Optimal Design

601 W. Campus Dr., Suite B3

Arlington Heights, IL  60004

Office: 847-818-1000 x 38

Fax: 847-483-1461
Mobile: 312-615-6431

 www.OptimalDesignCo.com <http://www.optimaldesignco.com/>


Follow Optimal Design on
Linkedin<http://www.linkedin.com/company/optimal-design>
, Twitter <https://twitter.com/#!/OptimalDesignCo> and
Facebook<http://www.facebook.com/pages/Optimal-Design/217642344936481>


More information about the ffmpeg-user mailing list