modified: myjupyterlab.sh
[GalaxyCodeBases.git] / perl / etc / justonce / tmp / ffp.pl
blob8ea8c0ca4481a8e37341ed3b6f17e22d0dda0045
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use threads;
6 die "Usage: $0 <TS file> <Out>.mkv [Split=15]\n" if @ARGV <2;
8 my ($fin,$fout,$nsplit)=@ARGV;
9 $nsplit = 15 unless defined $nsplit;
11 my $FFMPEG_BIN = 'ffmpeg-10bit';
12 $FFMPEG_BIN = './ffmpeg';
14 my $TcpPort0 = 12000;
15 #my @jobs;
16 my ($ffarmIDs,$PreOut,@ffarms,$foutIn);
18 my $fps1001o = 60000;
19 my $fps1001n = $fps1001o/$nsplit;
21 for my $j (1 .. $nsplit) {
22 my ($Port1,$Port2,$OutTag) = ($TcpPort0+$j,$TcpPort0+$nsplit+$j,"O$j");
23 #push @jobs,[$Port1,$Port2,$OutTag];
24 $ffarmIDs .= "[$OutTag]";
25 $PreOut .= " -map \'[$OutTag]\' -f yuv4mpegpipe tcp://localhost:$Port1?listen";
26 push @ffarms,"$FFMPEG_BIN -i tcp://localhost:$Port1 -vf owdenoise=8:0.309:0,fps=\'$fps1001n/1001\' -f yuv4mpegpipe tcp://localhost:$Port2?listen >$fout.p$j.log 2>&1";
27 $foutIn .= " -i tcp://localhost:$Port2";
30 sub doffarm() {
31 #system("AV_LOG_FORCE_COLOR=1 $_");
32 print "$_ &\n";
35 my $cmd = "$FFMPEG_BIN -threads 16 -i $fin -lavfi \"bwdif=send_field:tff,mcdeint=fast:tff:10,scale=w=iw:h=ih/2,drawtext=\'fontfile=arial.ttf:text=%{n}_%{pict_type}_%{pts}:fontcolor=Aqua:fontsize=32\',select=n=4:e=\'mod(n,$nsplit)+1\'$ffarmIDs\"$PreOut >$fout.pre.log 2>&1";
36 print "$cmd &\nsleep 3\n";
38 my %thread;
39 foreach (@ffarms) {
40 $thread{$_} = threads->new(\&doffarm, $_);
43 sleep 1;
45 #$cmd = "$FFMPEG_BIN $foutIn -lavfi [0:v][1:v][2:v][3:v]interleave=4,fps=\'60000/1001\' -pix_fmt yuv420p10le -vcodec libx264 -preset placebo -x264opts \'crf=23:vbv-maxrate=15000:vbv-bufsize=15000:threads=32:colormatrix=bt709:colorprim=bt709:transfer=bt709:psnr=1:ssim=1\' -vframes 1600 -f matroska -y $fout.mkv >$fout.cmp.log 2>&1";
46 $cmd = "$FFMPEG_BIN $foutIn -lavfi [0:v][1:v][2:v][3:v]interleave=4,fps=\'60000/1001\' -pix_fmt yuv420p10le -strict -1 -y -f yuv4mpegpipe - | mpv -";
47 #system("AV_LOG_FORCE_COLOR=1 $cmd");
48 print "sleep 2\n$cmd\n";
50 my %count;
51 foreach (sort keys %thread) {
52 $count{$_} = $thread{$_}->join;
55 #print "[m]done !\n";