I have a strange issue with sysread and postgres (and ffpeg/stderr)
If the main program throws an error sysread stops if I write to the
database (a log table)
this is the program (need open3 because ffmpeg writes to stderr not stdout)
use IPC::Open3;
my($file,$in, $out);
my $pid;
use Symbol 'gensym'; $file = gensym;
if ($soptsr->{command}=~/ffmpeg/){
$pid=open3(undef, undef, $file,$soptsr->{command},
@{$soptsr->{optsin}});# or die print "$!";
}
our $tag= Glib::IO->add_watch ( fileno($output), ['in', 'hup'], sub {
#local $SIG{__WARN__} = sub {};
my ($fileno, $condition,$tag) = @_;
if ($condition =~ /hup/) {
close $file;
Gtk3->main_quit();
return 1;
}
my $line ;
sysread $output, $line, 256 or die print $!;
my @line=split /\n/,$line;
foreach my $l (@line){
print $DBI::err,"\n";#,$ins->{errstr},"\n";
#print $condition,"\n";
#$ins->execute($soptsr->{transref},$soptsr->{fileid},$l);# if $l;
}
print "\n",$condition,"\t",$line,"\n";### this stops if I write todb with
prog error
return 1;
}
);
}
This is the output
[ in ] Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'/srv/data/Downloads/xxxxxxxxxxxxxxxxxx.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
Duration: 01:06:48.30, start: 0.000000, bitrate: 237 kb
[ in ] /s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 /
0x31637661), yuv420p, 426x240, 201 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc
(default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x613470
[ in ] 6D), 24000 Hz, mono, fltp, 32 kb/s (default)
Metadata:
handler_name : VideoHandler
### If I write to db output stops here ###
### If I dont the output continues ###
[ in ] Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[ in ] [AVFilterGraph @ 0x55b6655bf800] No such filter: '-setpts'
[ in ] Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
[ in ] Conversion failed!
Any ideas?
(I have fixed the error in the program, but I need to be able to log if I
have other errors)