# Record animation to mp4 with WGLMakie

**URL:** <https://discourse.julialang.org/t/record-animation-to-mp4-with-wglmakie/121508>\
**Category:** Visualization\
**Created:** [October 20, 2024, 4:44pm UTC](https://discourse.julialang.org/t/record-animation-to-mp4-with-wglmakie/121508 "2024-10-20T16:44:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [October 20, 2024, 4:44pm UTC](https://discourse.julialang.org/t/record-animation-to-mp4-with-wglmakie/121508/1 "2024-10-20T16:44:45Z")

</div>

I have a )I think) very simple problem, that I have tried to find a solution for for a long time today. I always run into the same error message no matter what.

I am in a Pluto notebook and I am using WGLMakie for plots. Pluto says I am on `WGLMakie v0.10.14`. Now, in some of my old codes (with GLMakie) I figured out (also a longish steep learning curve) how to record something with `record`

But If I do a Pluto cell with

```julia
begin
	using WGLMakie
	t = 0:0.01:1
	print(length(t))
	x = Observable(sin.(2π .* t))
	fig, ax, plt = plot(t,x)
	record(fig, "test.mp4", 1:50, framerate = 10) do i
        x[] = sin.( 2π .* 1/i .* t)
    end
end

```

I can do also the tips from [this old thread](https://discourse.julialang.org/t/wglmakie-animations/52084/3) but the only thing I get is

```julia
MethodError: no method matching wait_for_ready(::Nothing)
The function `wait_for_ready` exists, but no method is defined for this combination of argument types.

```

even when including the `yield`. Is there any easy way to record an animation as mp4 with WGLMakie?

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [October 21, 2024, 6:28am UTC](https://discourse.julialang.org/t/record-animation-to-mp4-with-wglmakie/121508/2 "2024-10-21T06:28:19Z")

</div>

Try putting the record into another Pluto cell. Let the plot render before you try to record it.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [October 21, 2024, 6:41am UTC](https://discourse.julialang.org/t/record-animation-to-mp4-with-wglmakie/121508/3 "2024-10-21T06:41:11Z")

</div>

Just moving the record to a next cell at least changes the error message and sounds a bit like I miss some understanding of how observables work 😉

So with

```julia
begin
	using WGLMakie
	t = 0:0.01:1
	print(length(t))
	x = Observable(sin.(2π .* t))
	fig, ax, plt = plot(t,x)
end

```

and a separate cell for

```julia
record(fig, "test.mp4", 1:50, framerate = 10) do i
     x[] = sin.( 2π .* 1/i .* t)
end

```

yields

```julia
BoundsError: attempt to access 600×450 Array{RGB{N0f8},2} with eltype ColorTypes.RGB{FixedPointNumbers.N0f8} at index [1:1200, 1:900]

```

_edit:_ With GLMakie with works perfectly find, though.

_edit2:_ Ah that error was maybe just a file that did not exist. If I now provide a file that does exist (i.e. that I can write to) I get the same error as in the original post.
