Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Commit

Permalink
Merge a56882f into 74680be
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Mar 7, 2017
2 parents 74680be + a56882f commit e4de913
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 140 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
Build status (Linux x86-64):
[![Build Status](https://ci.maleadt.net/buildbot/julia/png?builder=GLVisualize.jl:%20Julia%200.5%20(x86-64))](https://ci.maleadt.net/buildbot/julia/builders/GLVisualize.jl%3A%20Julia%200.5%20%28x86-64%29)

[![Coverage Status](https://coveralls.io/repos/github/JuliaGL/GLVisualize.jl/badge.svg?branch=HEAD)](https://coveralls.io/github/JuliaGL/GLVisualize.jl?branch=HEAD)


# GLVisualize

GLVisualize is an interactive 2D/3D visualization library completely written in OpenGL and Julia.
Its focus is on performance and allowing to display animations/interactions as smooth as possible.

#### Installation of GLVisualize
You need OpenGL 3.3, which should be available on most computers nowadays.
You need OpenGL 3.3, which should be available on most computers nowadays.
If you get an error like [this](https://github.com/JuliaGL/GLVisualize.jl/issues/129), please try updating your system/video driver.

Please run:
Expand All @@ -13,7 +19,7 @@ Pkg.add("GLVisualize")
Pkg.test("GLVisualize")
```

Running the tests will walk you through all examples.
Running the tests will walk you through all examples.
I made a recording of me giving a descriptions for every example:

[![glvisualize_tests](https://cloud.githubusercontent.com/assets/1010467/20456657/234e63dc-ae7b-11e6-9beb-fe49ea064aa8.png)](https://www.youtube.com/watch?v=WYX31vIkrd4&t=6s)
Expand Down Expand Up @@ -60,7 +66,7 @@ Note that the CPU version takes around 60 seconds for every iteration. GPU accel
# Documentation


Please visit [glvisualize.com](http://www.glvisualize.com/) .
Please visit [glvisualize.com](http://www.glvisualize.com/) .
Example code on the website is out of date, pleaser refer to [examples folder](https://github.com/JuliaGL/GLVisualize.jl/tree/master/examples) to get the newest versions.


Expand Down
9 changes: 9 additions & 0 deletions examples/documentation/documentation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using GLVisualize

# prints the documenation of parameters for visualizing a float matrix
get_docs(rand(Float32, 32, 32))
# prints the documenation of parameters for visualizing a float matrix in surface style
get_docs(rand(Float32, 32, 32), :surface)

# prints all visualization methods available with some documenation if available
all_docs()
80 changes: 0 additions & 80 deletions src/text/richtext.jl

This file was deleted.

67 changes: 10 additions & 57 deletions src/videotool.jl
Original file line number Diff line number Diff line change
@@ -1,63 +1,10 @@
"""
Takes `frames`, which is supposed to be an array of images,
saves them as png's at path and then creates an webm video
from that with the name `name`
"""
function create_video(frames::Vector, name, screencap_folder, resample_steps=0, remove_destination=true)
println("saving frames for $name")
cd(screencap_folder)
mktempdir() do path
frame1 = first(frames)
for i=1:resample_steps
frame1 = Images.restrict(frame1)
end
resolution = size(frame1)
for (i,frame) in enumerate(frames)
resampled = frame
for x=1:resample_steps
resampled = Images.restrict(resampled)
end
frame = map(RGB{N0f8}, resampled)
save(joinpath(path, "$name$i.png"), frame, true)
end
len = length(frames)
frames = [] # free frames...
oldpath = pwd()
cd(path)
mktemp(path) do io, path
# output stdout to tmpfile , since there is too much going on with it
run(pipeline(
`png2yuv -I p -f 30 -b 1 -n $len -j $name%d.png`,
stdout="$(name).yuv",stdin=io, stderr=io
))
run(pipeline(
`vpxenc --good --cpu-used=0
--auto-alt-ref=1 --lag-in-frames=16 --end-usage=vbr
--passes=1 --threads=4 --target-bitrate=3500
-o $(name).webm $(name).yuv`,
stdout=io, stdin=io, stderr=io
))
end
targetpath = abspath(joinpath(screencap_folder, "$(name).webm"))
sourcepath = abspath("$(name).webm")
mv(sourcepath, targetpath, remove_destination=remove_destination)
cd(oldpath)
end
end

function create_video(frame, name, path, resample_steps = 0)
println("saving static image for $name")
targetpath = abspath(joinpath(path, "$(name).png"))
for i=1:resample_steps
frame = Images.restrict(frame)
end
save(targetpath, frame, true)
end
#downsample
#`ffmpeg -i volume.webm -codec:v libvpx -quality good -cpu-used 0 -b:v 500k -qmin 10 -qmax 42 -maxrate 500k -bufsize 1000k -threads 4 -vf scale=-1:480 -codec:a libvorbis -b:a 128k volume2.webm`
# ffmpeg version
# ffmpeg -r 24 -pattern_type glob -i '*.png' -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4

"""
returns a stream and a buffer that you can use to not allocate for new frames.
Use `add_frame!(stream, window, buffer)` to add new video frames to the stream.
"""
function create_video_stream(path, window)
#codec = `-codec:v libvpx -quality good -cpu-used 0 -b:v 500k -qmin 10 -qmax 42 -maxrate 500k -bufsize 1000k -threads 8`
tex = GLWindow.framebuffer(window).color
Expand All @@ -66,12 +13,18 @@ function create_video_stream(path, window)
io, Array(RGB{N0f8}, res) # tmp buffer
end

"""
Adds a video frame to a stream created with `create_video_stream`
"""
function add_frame!(io, window, buffer)
#codec = `-codec:v libvpx -quality good -cpu-used 0 -b:v 500k -qmin 10 -qmax 42 -maxrate 500k -bufsize 1000k -threads 8`
tex = GLWindow.framebuffer(window).color
write(io, map(RGB{N0f8}, gpu_data(tex)))
end

"""
Converts a folder full of videos into a folder full of webm videos
"""
function webm_batchconvert(oldpath, newpath, scale = 0.5)
for file in readdir(oldpath)
isfile(file) || continue
Expand Down
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if isheadless()
run(`git fetch origin`)
run(`git checkout sd/warn`)
end
cd(Pkg.dir("GLAbstraction")) do
run(`git fetch origin`)
run(`git checkout sd/linenumbers`)
end
include("test_static.jl")
else
include("test_interactive.jl")
Expand Down

0 comments on commit e4de913

Please sign in to comment.