Created
December 6, 2015 16:33
-
-
Save milabs/84224927368dd751205e to your computer and use it in GitHub Desktop.
Wrapper for ffplay to watch RTSP disconnection without TEARDOWN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
no warnings 'once'; | |
my $cmd = "ffplay -nodisp -loglevel info rtsp://SERVER/live"; | |
pipe( READER, WRITER ) ; | |
my $child = open READER, '-|'; | |
defined $child or die "fork(): $!\n"; | |
if ( $child ) { | |
local $/ = "\r"; | |
my $threshold = 0; | |
while (my $line = <READER>) { | |
if ($line =~ /aq=\s+0KB/) { | |
last if (++$threshold > 32); next; | |
} | |
$threshold = 0; | |
} | |
} else { | |
open STDERR, '>&STDOUT'; | |
exec( $cmd ) or exit(1) ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment