Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH, MAINT: control "dead time" at end of mp4 movie renders? #15

Open
tylerjereddy opened this issue Feb 24, 2025 · 2 comments · May be fixed by #16
Open

ENH, MAINT: control "dead time" at end of mp4 movie renders? #15

tylerjereddy opened this issue Feb 24, 2025 · 2 comments · May be fixed by #16

Comments

@tylerjereddy
Copy link
Contributor

On the latest main branch (hash: cb9fb64) a simple 15-line script to render a quick movie with EEVEE engine (below the fold) seems to produce a large amount of "dead time" with identical frames at the end of the movie.

Reproducing Movie Making Code
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PSF, DCD
import ggmolvis
from ggmolvis.ggmolvis import GGMolVis
import bpy


ggmv = GGMolVis()
u = mda.Universe(PSF, DCD)
system = u.select_atoms("all")
all_mol = ggmv.molecule(system)
bpy.context.scene.render.engine = "BLENDER_EEVEE_NEXT"
all_mol.render(resolution=(1000, 1000),
               filepath="test.mp4",
               mode="movie")

Here is a sample of the movie produced (https://youtube.com/shorts/QoHMYdaPgGc?feature=share), with more than half of it representing "dead time" (MD frames where nothing happens). I did a visual inspection of the trajectory in VMD and confirmed there is no such "dead time"/dead frames in the actual trajectory.

I'll note that the number of frames generated by Blender is more than double the number of frames in the trajectory, but I'm not immediately certain this is a bug (could depend on sampling/interpolation/frame rate business, potentially?). In any case, perhaps it may be possible to use a sensible frame sampling default of some sort that might avoid this?

@BradyAJohnston
Copy link
Collaborator

BradyAJohnston commented Feb 24, 2025

If you boot up Blender, the default starting scene has a frame range from 1 - 250. The same default will apply when rendering using the bpy module.

In Molecular Nodes when importing via the GUI I ensure that the frame range is updated to match the length of the trajectory, but I've left this to be part of the import operator and it won't trigger when setting up a Trajectory, so that it isn't constantly changing when importing different files.

https://github.com/BradyAJohnston/MolecularNodes/blob/976eb660d3c1e4128cfaa2c410f62bb71a64da81/molecularnodes/entities/trajectory/ui.py#L106-L125

        context.scene.frame_start = 0
        context.scene.frame_end = niverse.trajectory.n_frames

A quick fix for the above script will be this:

import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PSF, DCD
import ggmolvis
from ggmolvis.ggmolvis import GGMolVis
import bpy


ggmv = GGMolVis()
u = mda.Universe(PSF, DCD)

bpy.context.scene.frame_start = 0
bpy.context.scene.frame_end = u.trajectory.n_frames

system = u.select_atoms("all")
all_mol = ggmv.molecule(system)
bpy.context.scene.render.engine = "BLENDER_EEVEE_NEXT"
all_mol.render(resolution=(1000, 1000),
               filepath="test.mp4",
               mode="movie")

This should probably be made to be part of the import code though.

tylerjereddy added a commit to tylerjereddy/ggmolvis that referenced this issue Feb 24, 2025
* Fixes yuxuanzhuang#15

* Add a new `frame_bounds` argument to `render()`, so that the start
and end frame may be controlled conveniently by the user when producing
a movie. I suppose the argument for why this should be available to
the user vs. using raw `bpy` would be similar to the argument in favor
of the original `frame` argument to render individual frames.

* I can add some regression tests, but I'll wait to see if folks
actually want this. The current testsuite still passes locally at least.
@tylerjereddy tylerjereddy linked a pull request Feb 24, 2025 that will close this issue
4 tasks
@tylerjereddy
Copy link
Contributor Author

Ah, very nice! I don't mind if the default frames are weird, but being able to control the render range seems useful to me--I proposed that in #16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants