From ca74f0dfd705bc58989c9752df501bcf855dcde5 Mon Sep 17 00:00:00 2001 From: Andinus Date: Wed, 3 Nov 2021 20:32:04 +0530 Subject: Generate slideshow with ffmpeg, add verbose option --- lib/Fornax/CLI.rakumod | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/Fornax') diff --git a/lib/Fornax/CLI.rakumod b/lib/Fornax/CLI.rakumod index 5ca60bb..7297903 100644 --- a/lib/Fornax/CLI.rakumod +++ b/lib/Fornax/CLI.rakumod @@ -17,6 +17,7 @@ proto MAIN(|) is export { unless so @*ARGS { put $*USAGE; exit }; {*} } multi sub MAIN( File $input, #= fornax format file (solved) Directory :$output = 'output', #= output directory (existing) + Bool :$verbose = True, #= verbosity ) is export { my Str @lines = $input.IO.lines; my Int() %meta{Str} = Metadata.parse(@lines.first).Hash @@ -69,7 +70,7 @@ multi sub MAIN( # Remove marker. $iter .= substr(1) if $status == Completed|Blocked; - put "$idx $iter $status"; + put "[fornax] $idx $iter $status" if $verbose; my @grid = $iter.comb.rotor: %meta; warn "Invalid grid: $idx $iter $status" unless @grid.elems == %meta; @@ -90,13 +91,13 @@ multi sub MAIN( given @grid[$r][$c] -> $cell { when $cell eq $VIS|$CUR { - .rgba: |%C, 0.8; - .rgba: |%C, 0.8 if $status == Completed; - .rgba: |%C, 0.8 if $status == Blocked; + .rgba: |%C, 0.64; + .rgba: |%C, 0.96 if $status == Completed; + .rgba: |%C, 0.96 if $status == Blocked; } - when $cell eq $BLOK { .rgba: |%C, 0.5 } + when $cell eq $BLOK { .rgba: |%C, 0.48 } when $cell eq $DEST { .rgb: |%C } - default { .rgb: |%C } + default { .rgba: |%C, 0.08 } } .fill :preserve; @@ -110,6 +111,11 @@ multi sub MAIN( .finish; } } + + put "[fornax] Generated images."; + put "[fornax] Creating a slideshow."; + run «ffmpeg -loglevel error -r 1 -i "$output/\%08d.png" + -vcodec libx264 -crf 28 -pix_fmt yuv420p "$output/solution.mp4"»; } multi sub MAIN( -- cgit 1.4.1-2-gfad0