Live555 Streaming Media and Android setup

Prashant Kumar Mishra
3 min readJun 29, 2022

--

I will explain here how to setup Live555, how to start Live555 server and play media file using Android VLC client.

What is Live555?

The “LIVE555 Media Server” is a complete RTSP server application. It can stream several kinds of media file (which must be stored in the current working directory.- i.e., the directory from which you launch the application — or a subdirectory.)

  • A MPEG Transport Stream file (with file name suffix “.ts”)
  • A Matroska or WebM file (with filename suffix “.mkv” or “.webm”)
  • An Ogg file (with filename suffix “.ogg”, “ogv”, or “.opus”)
  • A MPEG-1 or 2 Program Stream file (with file name suffix “.mpg”)
  • A MPEG-4 Video Elementary Stream file (with file name suffix “.m4e”)
  • A H.264 Video Elementary Stream file (with file name suffix “.264”)
  • A H.265 Video Elementary Stream file (with file name suffix “.265”)
  • A VOB video+audio file (with file name suffix “.vob”)
  • A DV video file (with file name suffix “.dv”)
  • A MPEG-1 or 2 (including layer III — i.e., ‘MP3’) audio file (with file name suffix “.mp3”)
  • A WAV (PCM) audio file (with file name suffix “.wav”)
  • An AMR audio file (with file name suffix “.amr”)
  • An AC-3 audio file (with file name suffix “.ac3”)
  • An AAC (ADTS format) audio file (with file name suffix “.aac”)

System Requirement:

  1. Live555 setup can be installed on Linux and MacOS
  2. System should have gcc installed
  3. Ensure you have appropriate compiler to build Live555 code.

$ sudo apt-get install build-essential

Downloads

  1. Download Live555 Media server from http://www.live555.com/mediaServer/#downloading link
  2. Download Live555 source code from http://www.live555.com/liveMedia/public/
  3. Copy above 2 download at some directory

Setup Steps

  1. Go to directory where you have copied all downloads.
  2. Run command from terminal $ tar xvf live555-latest.tar.gz to extract source code
  3. Change directory $ cd live
  4. Run command $ ./genMakefiles linux
  5. Run command $ make

Now live555 build is ready to run.

Start Live Server

  1. Go to director where you have coped live555MediaServer file
  2. Run command from terminal ./live555MediaServer

You can see above screen shot have RTSP stream details like “rtsp://<IP addresss>:<port>/<File you want play>”.

Now close this server and copy some video/audio media file as per supported format into live555MediaServer directory.

Again Run command from terminal ./live555MediaServer to start server

Now media file is available for stream.

Test Stream using VLC player

  1. Open VLC player
  2. Menu -> Media -> Open Network Stream

3. Press Play button.

Android Integration

  1. Add internet permission inside manifest file
  2. Add Gradle dependencies as “implementation ‘org.videolan.android:libvlc-all:3.4.4'
  3. Create a layout file as below,
?xml version="1.0" encoding="utf-8"?>
<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=".ui.player.MediaPlayer">

<org.videolan.libvlc.util.VLCVideoLayout
android:id="@+id/videoLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</RelativeLayout>

4. Create Activity class file as below,

import android.net.Uri
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.nabtopoc.R
import org.videolan.libvlc.LibVLC
import org.videolan.libvlc.Media
import org.videolan.libvlc.MediaPlayer
import org.videolan.libvlc.util.VLCVideoLayout

class MediaPlayer : AppCompatActivity() {

companion object {

private const val USE_TEXTURE_VIEW = false
private const val ENABLE_SUBTITLES = true
private const val URI = "rtsp://<Server IP:port>/test.264"
}
private lateinit var libVlc: LibVLC
private lateinit var mediaPlayer: MediaPlayer
private lateinit var videoLayout: VLCVideoLayout

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_media_player)

libVlc = LibVLC(this, ArrayList<String>().apply {
add("--no-drop-late-frames")
add("--no-skip-frames")
add("--rtsp-tcp")
add("-vvv")
})
mediaPlayer = MediaPlayer(libVlc)

videoLayout = findViewById(R.id.videoLayout)
}

override fun onStart() {
super.onStart()

mediaPlayer.attachViews(videoLayout, null, false, false)

val media = Media(libVlc, Uri.parse(URI))
media.setHWDecoderEnabled(true, false)
media.addOption(":network-caching=600")

mediaPlayer.media = media
media.release()
mediaPlayer.play()
}

override fun onStop() {
super.onStop()

mediaPlayer.stop()
mediaPlayer.detachViews()
}

override fun onDestroy() {
super.onDestroy()

mediaPlayer.release()
libVlc.release()
}
}

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Prashant Kumar Mishra
Prashant Kumar Mishra

No responses yet

Write a response