Animation from Player #217
-
Any suggestions how to get the ouput from player as a video file? :) Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
UPDATE March 2024From v0.14, we can export to an mp4 video using Player.to_video(). Original answer belowHi @sarkadava Step 1. ImportsWe import Kinetics Toolkit and the animation module from Matplotlib (since the Player uses Matplotlib). import kineticstoolkit.lab as ktk
import matplotlib.animation as animation Step 2. Create the player instance and assign a variable name to itplayer = ktk.Player(markers, ..., interconnections) # As you would do normally to view your scene Step 3. Navigate using the mouse to find the correct zoom, view point, etc.Step 4. Generate the animation and convert it to a video fileFor example, to generate # Convert the Player from an interactive window to a Maplotlib animation
anim = player._to_animation()
# Create a video writer with the selected fps. Every single frame will be drawn,
# and you choose at which speed they should be played in the video file.
writervideo = animation.FFMpegWriter(fps=30)
# Save the Matplotlib animation to an mp4 file
anim.save("test.mp4", writer=writervideo) This may take a little time to complete if your acquisition is long. If you want to only playback a portion of your acquisition, then you can use the TimeSeries' You may have to install the Important: This is an undocumented feature and it may break in any future release. But if you ask it, it may be because it's a common need. Do you think I should add a proper "to_mp4" method to the Player? It think I may. |
Beta Was this translation helpful? Give feedback.
-
Dear @felixchenier , |
Beta Was this translation helpful? Give feedback.
UPDATE March 2024
From v0.14, we can export to an mp4 video using Player.to_video().
Original answer below
Hi @sarkadava
There is no official way yet, but there are two good solutions that may work well. The first is to simply use a screen recorder to create a video from what is shown on the screen. The second, which is probably more what you are looking for, is to use a private method of the Player that I use to generate the website:
Player._to_animation
.Step 1. Imports
We import Kinetics Toolkit and the animation module from Matplotlib (since the Player uses Matplotlib).
Step 2. Create the player instance and as…