Open Ipuch opened 2 years ago
Hi @Ipuch
export in mpeg4.
mpeg4 won't be possible... In general, messing with codec is enough to want to kill yourself haha! We will stick with non proprietary format (ogv) and people can reformat if needed.
Export a video directly from command lines.
It is obviously already possible to run in command line (as a button is just a fancy way to call a command line :) )
Get the same frame rate when two or more phases are in the same OCP.
bioviz is unfortunately agnostic of this "phase concept". This is solely bioptim
based... To have the same framerate, you must use do it in bioptim
(which has already this feature implemented)
@EveCharbie and @mickaelbegon
export in mpeg4.
can't we do something like this : https://askubuntu.com/questions/12182/how-can-i-convert-an-ogv-file-to-mp4 + https://stackoverflow.com/questions/32714579/ffmpeg-converts-anything-to-mp4 ?
Get the same frame rate when two or more phases are in the same OCP.
I think what we would like is to have the option to give bioviz a time vector and a Q matrix matching together so that the frame rate of the recorded video is approximately fixed at the real time. (I think I saw a sleep command that we could play with, but I would have to look again).
can't we do something like this : https://askubuntu.com/questions/12182/how-can-i-convert-an-ogv-file-to-mp4 + https://stackoverflow.com/questions/32714579/ffmpeg-converts-anything-to-mp4 ?
Yep, but these as bash
command lines. That is exactly as if the user would open a terminal and type them in. This means ffmpeg must be installed first. The GUI wrapper in Linux is WinFF
which you may be already aware of.
This is not a portable solution (nor that it is an actual Python solution). And again, it relies on the presence of codecs for both the container (.mp4, .mov, .Whatever) and the format (MPEG-4). Codecs are insanely complex to deal with. I strongly advice against anything towards this. Get a OGV (non-proprietary file) and then use ffmpeg (or any other tool) to convert locally. It can even be done automatically if needed.
Frame rate
Sleeping would do nothing. The frame rate is solely based on the amount of frame you record for a particular time period. For instance, if you hit "record" twice at each frame, you have a video which is twice slower. You however maybe can change the frame rate of the actual video (not sure about that). But it is going to be hard to decide what you should do or not.
My advice, the video is currently 30fps (if I recall well), therefore resample using animate
in bioptim
Turns out, it wasn't accessible (it was defined in private methods), and that I needed this as the same time ;) So #68 added the capability to record from command line as such:
import bioviz
import numpy as np
# This should be real data
all_q = np.random.rand(n_dof, n_frames) # n_dof is the number of dof of the model
# Load a bioviz handler
b = bioviz.Viz("model_path.bioMod")
b.resize(1920, 1080) # Make it nice and big
b.start_recording("save_path")
for q in all_q:
b.set_q(q)
b.add_frame() # Add a frame to the video
b.stop_recording()
# Close the window
b.quit()
is it possible to specify a view angle ? :)
There is no direct API for this, but the vtk renderer is actually public. So you can get the camera like this:
cam = b.vtk_window.ren.GetActiveCamera()
cam.SetPosition(x, y, z)
cam.SetRoll(angle)
b.refresh_window() # This is not necessary, but you won't visually see the changes
Please refer to the VTK documentation for further help
Hello,
It would be great features to: