Skip to content

Commit

Permalink
Merge branch 'master' into jk/datashader
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch authored Aug 21, 2023
2 parents c3176b0 + e1340ce commit 2463441
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ DelaunayTriangulation = "927a84f5-c5f4-47a5-9785-b46e178433df"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a"
FFMPEG_jll = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"
Expand Down Expand Up @@ -68,7 +68,6 @@ Contour = "0.5, 0.6"
DelaunayTriangulation = "0.6.2, 0.7"
Distributions = "0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25"
DocStringExtensions = "0.8, 0.9"
FFMPEG = "0.2, 0.3, 0.4"
FileIO = "1.6"
FixedPointNumbers = "0.6, 0.7, 0.8"
Formatting = "0.4"
Expand Down
1 change: 0 additions & 1 deletion ReferenceTests/src/ReferenceTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ using FileIO
using MacroTools
using Makie
using Makie: Record, Stepper, Axis
using Makie.FFMPEG
using Printf
using Tar
using Downloads
Expand Down
2 changes: 1 addition & 1 deletion docs/documentation/animation.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ record(change_function, fig, "color_animation.mp4", hue_iterator; framerate = fr

## File formats

Video files are created with [`FFMPEG.jl`](https://github.com/JuliaIO/FFMPEG.jl).
Video files are created with [`FFMPEG_jll.jl`](https://github.com/JuliaBinaryWrappers/FFMPEG_jll.jl).
You can choose from the following file formats:

- `.mkv` (the default, doesn't need to convert)
Expand Down
2 changes: 1 addition & 1 deletion src/Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ using Base64
using LaTeXStrings
using MathTeXEngine
using Random
using FFMPEG # get FFMPEG on any system!
using FFMPEG_jll # get FFMPEG on any system!
using Observables
using GeometryBasics
using PlotUtils
Expand Down
15 changes: 7 additions & 8 deletions src/ffmpeg-util.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ you have issues playing a video, try `profile = "high"` or `profile = "main"`.
- `pixel_format = "yuv420p"`: A ffmpeg compatible pixel format (`-pix_fmt`). Currently only
applies to `mp4`. Defaults to `yuv444p` for `profile = high444`.
- `loop = 0`: Number of times the video is repeated, for a `gif`. Defaults to `0`, which
means infinite looping. A value of `-1` turns off looping, and a value of `n > 0` and above
means infinite looping. A value of `-1` turns off looping, and a value of `n > 0` and above
means `n` repetitions (i.e. the video is played `n+1` times).
!!! warning
Expand All @@ -48,12 +48,12 @@ struct VideoStreamOptions
function VideoStreamOptions(
format::AbstractString, framerate::Real, compression, profile,
pixel_format, loop, loglevel::String, input::String, rawvideo::Bool=true)

if !isa(framerate, Integer)
@warn "The given framefrate is not a subtype of `Integer`, and will be rounded to the nearest integer. To supress this warning, provide an integer as the framerate."
framerate = round(Int, framerate)
end

if format == "mp4"
(profile === nothing) && (profile = "high422")
(pixel_format === nothing) && (pixel_format = (profile == "high444" ? "yuv444p" : "yuv420p"))
Expand All @@ -62,7 +62,7 @@ struct VideoStreamOptions
if format in ("mp4", "webm")
(compression === nothing) && (compression = 20)
end

if format == "gif"
(loop === nothing) && (loop = 0)
end
Expand Down Expand Up @@ -131,7 +131,6 @@ function to_ffmpeg_cmd(vso::VideoStreamOptions, xdim::Integer=0, ydim::Integer=0

cpu_cores = length(Sys.cpu_info())
ffmpeg_prefix = `
$(FFMPEG.ffmpeg)
-y
-loglevel $(vso.loglevel)
-threads $(cpu_cores)`
Expand Down Expand Up @@ -229,7 +228,7 @@ function VideoStream(fig::FigureLike;
buffer = Matrix{RGB{N0f8}}(undef, xdim, ydim)
vso = VideoStreamOptions(format, framerate, compression, profile, pixel_format, loop, loglevel, "pipe:0", true)
cmd = to_ffmpeg_cmd(vso, xdim, ydim)
process = @ffmpeg_env open(`$cmd $path`, "w")
process = open(`$(FFMPEG_jll.ffmpeg()) $cmd $path`, "w")
return VideoStream(process.in, process, screen, buffer, abspath(path), vso)
end

Expand Down Expand Up @@ -277,10 +276,10 @@ function convert_video(input_path, output_path; video_options...)
format = lstrip(typ, '.')
vso = VideoStreamOptions(; format=format, input=input_path, rawvideo=false, video_options...)
cmd = to_ffmpeg_cmd(vso)
@ffmpeg_env run(`$cmd $output_path`)
return run(`$(FFMPEG_jll.ffmpeg()) $cmd $output_path`)
end

function extract_frames(video, frame_folder; loglevel="quiet")
path = joinpath(frame_folder, "frame%04d.png")
FFMPEG.ffmpeg_exe(`-loglevel $(loglevel) -i $video -y $path`)
run(`$(FFMPEG_jll.ffmpeg()) -loglevel $(loglevel) -i $video -y $path`)
end

0 comments on commit 2463441

Please sign in to comment.