Skip to content

Commit

Permalink
Merge cb3932d into 53f6118
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Sep 28, 2019
2 parents 53f6118 + cb3932d commit 4428652
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
18 changes: 9 additions & 9 deletions docs/src/reading.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,23 @@ VideoIO.viewcam()

An expanded version of this approach:
```julia
import Makie
import VideoIO
import Makie, VideoIO

io = VideoIO.open(video_file)
f = VideoIO.openvideo(io)
cam = VideoIO.opencamera()

img = read(f)
scene = Makie.Scene(resolution = size(img))
img = read(cam)
scene = Makie.Scene(resolution = size(img'))
makieimg = Makie.image!(scene, img, show_axis = false, scale_plot = false)[end]
Makie.rotate!(scene, -0.5pi)
display(scene)

while !eof(f)
read!(f, img)
while isopen(scene)
read!(cam, img)
makieimg[1] = img
sleep(1/f.framerate)
sleep(1/cam.framerate)
end

close(cam)
```

## Video Properties & Metadata
Expand Down
18 changes: 7 additions & 11 deletions docs/src/writing.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,23 @@ For instance:
```julia
using VideoIO, ProgressMeter

imgnames = filter(x->occursin(".png",x),readdir()) # Populate list of all .pngs
dir = "" #path to directory holding images
imgnames = filter(x->occursin(".png",x),readdir(dir)) # Populate list of all .pngs
intstrings = map(x->split(x,".")[1],imgnames) # Extract index from filenames
p = sortperm(parse.(Int,intstrings)) #sort files numerically
imgnames = imgnames[p]

filename = "manual.mp4"
filename = "video.mp4"
framerate = 24
props = [:priv_data => ("crf"=>"22","preset"=>"medium")]

firstimg = read(imgnames[1])
firstimg = load(joinpath(dir,imgnames[1]))
encoder = prepareencoder(firstimg, framerate=framerate, AVCodecContextProperties=props)

io = Base.open("temp.stream","w")
p = Progress(length(imgstack), 1)
index = 1
for imgname in imgnames
global index
img = read(imgname)
appendencode!(encoder, io, img, index)
next!(p)
index += 1
@showprogress "Encoding video frames.." for i in 1:length(imgnames)
img = load(joinpath(dir,imgnames[i]))
appendencode!(encoder, io, img, i)
end

finishencode!(encoder, io)
Expand Down

0 comments on commit 4428652

Please sign in to comment.