69 lines
2.2 KiB
Perl
69 lines
2.2 KiB
Perl
#!/usr/bin/perl
|
|
# Author: Dominik Danter
|
|
# Version: 0.01
|
|
# Purpose:
|
|
# Tiny VLC wrapper that streams the file provided as argument. This can be used
|
|
# as a Nautlius-Script. It just works on one file yet.
|
|
#
|
|
# Just a litte Script that by default opens two instances of vlc.
|
|
#
|
|
# The first one will stream the passed files with the real time streaming
|
|
# protocol (rtsp) at $rtsspport. If the device $dev (e.g. 'eth0')
|
|
# has got a valid IPv4 address you can control the sever at
|
|
# {address of device}:$httpport. Note: localhost:$httpport will NOT work.
|
|
#
|
|
# If you do not wish this behaviour assign a false value to $httpport
|
|
# (my $httpport = 0; for example).
|
|
#
|
|
# You can control access to this webserver in the .hosts file
|
|
# (on ubuntu one can find this file in /usr/share/vlc/http).
|
|
#
|
|
# At the moment just one server instance will work.
|
|
#
|
|
# The second instance will indefinitely repeatedly listen on
|
|
# localhost:$rtspport and serves as the client, for local playback.
|
|
# If you do not wish local playblack assign a false value to
|
|
# $localplayback (my $localplayback = 0; for example);
|
|
#
|
|
# Todo:
|
|
# Check requirements first and die if they are not met.
|
|
# Implement a more versatile way of passing options to vlc.
|
|
# Support IPv6 by altering the regex.
|
|
|
|
use strict;
|
|
use warnings;
|
|
use v5.12;
|
|
|
|
#settings
|
|
my $dev = 'eth0'; #Your favourite interface here, maybe 'eth0';
|
|
my $httpport = 8080; #unsetting this will disable the webserver
|
|
my $rtspport = 5544;
|
|
my $localplayback = 1; #set to 0 if you do not wish local playback
|
|
#end settings
|
|
|
|
#if no arguments ar passed die
|
|
@ARGV > 0 or die "you forgot to pass some filenames to $0";
|
|
|
|
my $http = "";
|
|
|
|
#get ip addr of $dev
|
|
$_ = `ip addr show $dev`;
|
|
my ($address) = /inet ((\d\d?\.){3}\d\d?)/;
|
|
if ($address && $httpport) {
|
|
$http = "--extraintf http --http-host $address:$httpport ";
|
|
}
|
|
|
|
#escape arguments (samplemovie.avi to "samplemovie.avi");
|
|
@ARGV = map{ $_ = '"'.$_.'"' } @ARGV;
|
|
|
|
#start server
|
|
system "vlc @ARGV $http:sout=#rtp{sdp=rtsp://:$rtspport/} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep &";
|
|
|
|
#pause
|
|
sleep(1);
|
|
|
|
#start client if applicable
|
|
system "vlc --repeat rtsp://localhost:$rtspport/" if $localplayback;
|
|
|
|
#ich mag Schokolade gern
|