Repository: Wikunia/Javis.jl (julia)

Issue:
ffmpeg not installed by default on windows
So I can't use javis which is calling ffmpeg.

I had to install it and set my path. 99% of users won't know how to do it.

Perhaps binarybuilder.jl can help?

I want to help but I may not get to it soon enough.

Pull request:
Fix #53 

This should remove the necessity to install FFMPEG which might be a pain for Windows users.

Patch:
diff --git a/Project.toml b/Project.toml
index 3f1fbf854..c03fa1849 100644
--- a/Project.toml
+++ b/Project.toml
@@ -4,11 +4,13 @@ authors = ["Ole Kröger <o.kroeger@opensourc.es> and Jacob Zelko <jacobszelko@gm
 version = "0.1.0"
 
 [deps]
+FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
 LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
 LightXML = "9c8b4983-aa76-5018-a973-4c85ecc9e179"
 Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
 
 [compat]
+FFMPEG = "0.4"
 LaTeXStrings = "1.1"
 LightXML = "0.9"
 Luxor = "2"
diff --git a/src/Javis.jl b/src/Javis.jl
index e05637776..5976d4994 100644
--- a/src/Javis.jl
+++ b/src/Javis.jl
@@ -1,5 +1,6 @@
 module Javis
 
+using FFMPEG
 using LaTeXStrings
 using LightXML
 using Luxor
@@ -647,7 +648,10 @@ function javis(
     end
 
     !creategif && return 
-    run(`ffmpeg -loglevel panic -framerate $(framerate) -f image2 -i $(tempdirectory)/%10d.png -filter_complex "[0:v] split [a][b]; [a] palettegen=stats_mode=full:reserve_transparent=on:transparency_color=FFFFFF [p]; [b][p] paletteuse=new=1:alpha_threshold=128" -y $(pathname)`)
+    # generate a colorpalette first so ffmpeg does not have to guess it
+    ffmpeg_exe(`-loglevel panic -i $(tempdirectory)/%10d.png -vf "palettegen=stats_mode=diff" -y "$(tempdirectory)/palette.bmp"`)
+    # then apply the palette to get better results
+    ffmpeg_exe(`-loglevel panic -framerate $framerate -i $(tempdirectory)/%10d.png -i "$(tempdirectory)/palette.bmp" -lavfi "paletteuse=dither=sierra2_4a" -y $pathname`)
     !deletetemp && return 
     run(`rm -rf $(tempdirectory)`)
     mkpath(tempdirectory)


Test patch:
diff --git a/test/animations.jl b/test/animations.jl
index 7b1660276..f0242af13 100644
--- a/test/animations.jl
+++ b/test/animations.jl
@@ -42,12 +42,15 @@ end
         Action(1:25, (video, args...)->path!(path_of_red, pos(:red_ball), "red")),
         Action(1:25, (video, args...)->path!(path_of_blue, pos(:blue_ball), "blue")),
         Action(1:25, (args...)->rad(pos(:red_ball), pos(:blue_ball), "black"))
-    ], tempdirectory="images")
+    ], tempdirectory="images", creategif=true, pathname="dancing.gif")
 
     @test_reference "refs/dancing_circles_16.png" load("images/0000000016.png")
+    @test isfile("dancing.gif")
     for i=1:25
         rm("images/$(lpad(i, 10, "0")).png")
     end
+    rm("images/palette.bmp")
+    rm("dancing.gif")
 end
 
 @testset "Dancing circles layered" begin 
diff --git a/test/unit.jl b/test/unit.jl
index 533bc7868..6741d08a9 100644
--- a/test/unit.jl
+++ b/test/unit.jl
@@ -34,7 +34,6 @@ end
     video = Video(500, 500)
     # dummy action doesn't need a real function
     action = Action(1:100, ()->1, Translation(Point(99, 99)))
-    println(action)
     # needs internal translation as well
     push!(action.internal_transitions, Javis.InternalTranslation(O))