[FFmpeg-user] Real-time streaming of rawdata images to Android with FFMPEG

Philipp Thies philies.stack at gmail.com
Wed Jul 29 16:34:08 CEST 2015


*Hello :)*

*CONDITIONS*

I have an C++ server (Linux) and want to transmit rawdata images (RGB,
32bit) to an Android device in real-time. The server generates the rawdata
images (with or without bitmap header) continuously every x miliseconds.
Now, I want to put the rawdata images into a stream and transmit them
without much delay to the Android client.

I've chosen FFMPEG for this kind of job.

The input for FFMPEG should be the rawdata images, which are generated just
in time. The output should be an rtsp stream (h264 or is another format
better?). On client side I will play the stream with the Android
MediaPlayer. That works for a RTSP url like
rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov
<http://rtsp//184.72.239.149/vod/mp4:BigBuckBunny_115k.mov>
------------------------------

*PREVIOUS APPROCH:*

I've installed FFMPEG on my server (192.168.1.20).

Depending on this question:
https://ffmpeg.org/pipermail/ffmpeg-user/2013-April/014617.html ... here is
my FFMEG command:

ffmpeg -an -f rawvideo -vcodec rawvideo -pix_fmt rgb32 -r 10 -i
-vcodec libx264 -r 30 -tune zerolatency -preset ultrafast -bsf:v
h264_mp4toannexb  http://192.168.1.20:8090/feed1.ffm

*Explanation of the parameters:*

   - -an = ignore audio
   - -report = log file in current directory

*INPUT:*

   - -f = rawvideo (video format)
   - -vcodec = rawvideo (video codec)
   - -pix_fmt = rgb32
   - -r = 10 (frame rate)

*OUTPUT:*

   - -vcodec = libx264
   - -r = 30 (frame rate)
   - -bsf:v = h264_mp4toannexb

------------------------------

*C++ Server Code Snippet:*

/* -------  Get image rawdata from source ------- */.../* -------
Create image header which fits to the image rawdata ------- */...
/* ------- Store the picture local (not necessary?) ------- */FILE *f;
f = fopen("/home/philies/test.bmp","wb");
//Write Bitmap Headers
fwrite(&imageFileHeader,1,sizeof(imageFileHeader),f);
fwrite(imageInfoHeader,1, imageInfoHeader,f);
//Write Bitmap Rawdata
fwrite(lastImage.GetBitmapRawData(),1,imageSize,f);

—> ffmpeg ???

------------------------------

*ffserver.conf* After that I will set up a FFserver to create a RTSP stream
like that. Is it also correct?

Port 8090BindAddress 0.0.0.0RTSPPort 7654RTSPBindAddress
0.0.0.0MaxClients 10MaxBandwidth 10000NoDaemon
<Feed feed1.ffm>File /tmp/feed1.ffmFileMaxSize 30M
ACL allow 127.0.0.1
ACL allow 192.168.1.0 192.168.1.255
ACL allow 192.168.5.0 192.168.5.255
</Feed>
<Stream mystream.sdp>Feed feed1.ffmFormat rtpVideoCodec
libx264VideoSize 640x480AVOptionVideo flags
+global_headerNoAudio</Stream>

------------------------------

*PROBLEMS/QUESTIONS:*

   1.

   How can I specify the rawvideo of the ffmpeg command respectively how
   can I specify my bitmap rawdata (with or without header?) as the input of
   the FFMPEG?
   2.

   Is the FFMPEG command correct?
   3.

   Is the ffserver.conf correct?

If I fire the FFMPEG command in the terminal I get this error:

vcodec: no such file or directory

------------------------------

*Android Device (192.168.5.5):*

VideoView videoView
=(VideoView)findViewById(R.id.VideoView);MediaController
mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
Uri uri = Uri.parse("rtsp://192.168.1.20:7654/mystream.sdp");

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


More information about the ffmpeg-user mailing list