Skip to content

Instantly share code, notes, and snippets.

@abaez
Created April 10, 2013 15:43
Show Gist options
  • Save abaez/5355772 to your computer and use it in GitHub Desktop.
Save abaez/5355772 to your computer and use it in GitHub Desktop.
a vlc sdp stream script
#!/usr/bin/perl
# Stream set for vlc
use IO::Handle;
##### Phase1
# Definitions for the stream
$path = "/data/Videos";
chdir $path or die "can't chdir to $path $!";
$port="12345";
$file="$path/vlc.sdp";
#$vcodec="theo";
#$acodec="vorb";
$vcodec="h264";
$acodec="mpga";
# Receive the format of the stream
print "Give me what format you want:\t std, lo, hi\n";
chomp ($type = <STDIN>);
sub done {
my $vb, $ab, $samplerate, $complete;
my $type = $_[0];
($type =~ /lo/i) ? ($vb=800,$ab=128,$samplerate=22050) :
($type =~ /std/i) ? ($vb=800, $ab=192,$samplerate=44100) :
($type =~ /hi/i) ? ($vb=2000,$ab=256, $samplerate=48000) :
die "You didn't give a definition that's proper\n"; # check to make sure the loop is smooth
$complete= "--sout='#transcode{vcodec=$vcodec,vb=$vb,scale=1,acodec=$acodec,ab=$ab,channels=2,samplerate=$samplerate}:rtp{dst=127.0.0.1,port=$port,sdp=file://$file}' :no-sout-rtp-sap :ttl=1 :sout-keep";
return $complete; #($vb, $ab, $samplerate);
}
#($vb, $ab, $samplerate) = &done($type); #using the function done to assess what type of stream to do
$com = &done($type);
#Video stream
print "Give me a video to stream bitches!\n";
chomp($input = <STDIN>);
#Run the Stream
system "cvlc -vvv $com $input "; #pull to the background with &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment