Skip to content

Instantly share code, notes, and snippets.

@kentfredric
Created June 14, 2013 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kentfredric/5786099 to your computer and use it in GitHub Desktop.
Save kentfredric/5786099 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use utf8;
my $mplayer = 'mplayer2';
use File::Temp;
my $tempdir = File::Temp::tempdir;
my $fifo = "$tempdir/fifo";
my $uri = 'http://livestream-f.akamaihd.net/3585172_2037842_92237207_1_2096@108752?v=2.10.3&fp=LNX%2011,2,202,285&r=SWSSE&g=JCYHBTYEMDIW';
my $i = 21490;
my $end = 25550;
my $step = 16;
print "making fifo $fifo\n";
system('mkfifo', $fifo);
my @extra = qw( -slave -ao pulse );
local $SIG{CHLD} = sub { die "Child process died" };
my $pid = fork;
if ( not defined $pid ){
die "Fork failed";
}
if ( $pid ){
print "spawning mplayer slave \n";
system($mplayer, @extra,'-nocache', '-input', 'file=' . $fifo , $uri . '&seek=' . $i );
exit;
}
print "Writing to fifo\n";
open my $wfh, '>' , "$fifo" or die "Cant write to fifo";
$i+= $step;
$wfh->autoflush(1);
while( $i <= $end ){
print "[lwall] Queing $i\n";
$wfh->print("loadfile $uri&seek=$i 1\n") or die "FIFO Closed";
$i+=$step;
sleep 1;
}
waitpid $pid, -1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment