The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


RTSP::Lite - Lightweight RTSP implementation


  use RTSP::Lite;
  $rtsp = new RTSP::Lite;
  $status_code = $rtsp->status();
  $status_message = $rtsp->status_message();
  print "$status_code $status_message\n";
  print $rtsp->body();


RTSP::Lite is a stand-alone lightweight RTSP/1.0 module for Perl. It is based on Roy Hooper's HTTP::Lite (RTSP protocol is very similar to HTTP protocol. I simply modified it to support RTSP).

The main focus of the module is to help you write simple RTSP clients for monitoring and debugging streaming server. So far, full streaming clients that need RTP handling are out of my scope.

The main modifications from the HTTP::Lite 2.1.4 are: + Supports continuous requests. Therefore explicit open operation is now required. + Supports multiple debug level. + Callback function is not supported. + Deletes http style proxy support. Because RTSP requests to proxy are the same style of requests to server.


debug ( $level)

Set the debug level. 0: no debug message (default), 1: display all network write and read 2: display all debug message

open ( $host, $port )

Open a connection to $host:$port. $port can be left out.

method ( $method )

Set the method name (OPTIONS, DESCRIBE, PLAY, ...).

add_req_header ( $header, $value )
get_req_header ( $header )
delete_req_header ( $header )

Add, Delete, or get RTSP header(s) for the request.

user_agent( $agent_name)

Set the agent name (Default is "RTSP::Lite 0.1").

request ( $url )

Send a request to the connected host. If an I/O error is encountered, it returns undef, otherwise RTSP status code is returned.

Note: user-agent and cseq headers are automatically added. If user agent header is specified by add_req_header (), it overwrites the user_agent () variable;

body ()

Returns the body of the response.

status ()

Returns the status code received from the RTSP server

status_message ()

Returns the textual description of the status code received from the RTSP server.

headers_array ()

Returns an array of the RTSP headers received from the RTSP server.


Returns a string representation of the RTSP headers received from the RTSP server.

get_header ( $header )

Returns an array of values for the received response.

reset ()

You must call this prior to re-using an RTSP::Lite file handle, otherwise the results are undefined.

local_addr ( $ip )
local_port ( $port )

Explicitly select the local IP address (default and the local port (default 0: automatic selected by system).


rtsp-request: command line RTSP request tool (

sample scripts that included in the distribution file

SETUP & PLAY sample #!/usr/bin/perl use RTSP::Lite; $url = "rtsp://"; $rtsp = new RTSP::Lite; ## open the connection $req = $rtsp->open("",554) or die "Unable to open: $!";

  ## SETUP
  $req = $rtsp->request($url."/streamid=0");

  my $se = $rtsp->get_header("Session");
  $session = @$se[0];
  print $rtsp->status_message();
  ## Play
  $req = $rtsp->request($url);
  print $rtsp->status_message();
  ## You will get RTP/RTCP packets, you need to have codes for them.
  sub print_headers {
    my @headers = $rtsp->headers_array();
    my $body = $rtsp->body();
    foreach $header (@headers) {
      print "$header\n";


Masaaki NABESHIMA <>


 RFC 2326 - Real Time Streaming Protocol (RTSP)
 HTTP::Lite module (


This module is a deviation of HTTP::Lite, maintained by Roy Hooper. Without it this module never exist.


Copyright (c) 2003, Masaaki NABESHIMA. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


The latest version of this module is available at:

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 730:

'=item' outside of any '=over'

Around line 803:

You forgot a '=back' before '=head1'