#!/usr/bin/perl use Getopt::Long; use IO::Handle; STDERR->autoflush(1); STDOUT->autoflush(1); my $tag = "pix2pixhd_" . time; my $module = "pix2pixhd"; my $endpoint = undef; GetOptions ( "tag" => \$tag, "module" => \$module, "endpoint" => \$endpoint ) or die("Error in command line arguments\n"); $tag =~ s/\....$//; if (! -e "results/$tag") { print "usage: $0 [tag]\n"; exit(1); } chdir('results/$tag'); my $i = 0; my $ls = `ls -1v *.png`; my @lines = split('\n', $ls); my $pwd = `pwd`; chomp $pwd; $pwd .= '/'; print $pwd . "\n"; mkdir('./tmp'); for my $line (@lines) { chomp $line; system('ln', '-s', $pwd . $line, sprintf('./tmp/frame_%05d.png', $i)); $i += 1; } system("ffmpeg", "-i", "./tmp/frame_%05d.png", "-y", "-c:v", "libx264", "-vf", "fps=25", "-pix_fmt", "yuv420p", "-s", "1024x512", "../../renders/" . $tag . ".mp4" ); if (defined $endpoint) { print("upload to $endpoint\n"); system("curl", "-X", "POST", "-F", "module=$module", "-F", "activity=live", "-F", "generated=true", "-F", "dataset=$tag", "-F", "file=@../../renders/$tag.mp3", $endpoint ); } print "rendered: $tag.mp4\n"; END { system('rm', '-rf', 'tmp'); chdir('../..'); }