Skip to content

Commit

Permalink
Prevent ffmpeg hanging everything up, fix indentation
Browse files Browse the repository at this point in the history
Using ffmpeg would cause everything to hang-up because of stdout/stderr
readings blocking yadda-yadda. Solved by combining the 2, preventing
blocking. Also fixes some indentation because I'm nitpicky.
  • Loading branch information
CaptainJet committed Jun 25, 2015
1 parent 9d4d28a commit e155b34
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions UnlinkMKV-GUI/UnlinkMKV-GUI/winport.pl
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ package UnlinkMKV {
@aopt = undef;
@aopt = qw/-map 0 -acodec ac3 -ab 320k/;
}
$self->sys($self->{opt}->{ffmpeg}, '-i', "\"" . $part . "\"", @vopt, @aopt, "\"" . "$part-fixed.mkv" . "\"");
$self->sys($self->{opt}->{ffmpeg}, '-i', "\"" . $part . "\"", @vopt, @aopt, "\"" . "$part-fixed.mkv" . "\"", '2>&1');
$self->replace($part, "$part-fixed.mkv");
}
less();
Expand Down Expand Up @@ -555,7 +555,7 @@ package UnlinkMKV {
my $file = shift;
my $size = int(((-s $file)/1024+.5)*1.1);
my $br = 2000;
foreach my $line (split /\n/, $self->sys($self->{opt}->{ffmpeg}, '-i', $file)) {
foreach my $line (split /\n/, $self->sys($self->{opt}->{ffmpeg}, '-i', $file, '2>&1')) {
if($line =~ /duration: (\d+):(\d+):(\d+\.\d+),/i) {
my $duration = ($1*3600)+($2*60)+int($3+.5);
$br = int(($size / $duration)+.5);
Expand Down Expand Up @@ -626,7 +626,7 @@ package UnlinkMKV {


# We use this instead of CRC32 so we can avoid requiring compiling native C code for usage
sub mycrc32 {
sub mycrc32 {
my ($input, $init_value, $polynomial) = @_;

$init_value = 0 unless (defined $init_value);
Expand Down Expand Up @@ -655,7 +655,7 @@ package UnlinkMKV {
$crc = $crc ^ 0xffffffff;

return $crc;
}
}



Expand Down Expand Up @@ -808,16 +808,16 @@ package UnlinkMKV {
my ($pid, $in, $out, $err, $sel, $buf);
my $cmd = "$app @_";
TRACE "sys > $cmd";
my $dbuffer = `$cmd`;
return $dbuffer;
my $dbuffer = `$cmd`;
return $dbuffer;

$err = gensym();
more();

$pid = open3($in, $out, $err, $app, @_) or LOGDIE "failed to open $app: @_";
$sel = new IO::Select;
$sel->add($out,$err);
SYSLOOP: while(my @ready = $sel->can_read) {
while(my @ready = $sel->can_read) {
foreach my $fh (@ready) {
my $line = <$fh>;
if(not defined $line) {
Expand Down

0 comments on commit e155b34

Please sign in to comment.