Skip to content

Commit

Permalink
fix: add fps to video exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
nmvrs committed Jan 2, 2025
1 parent b793566 commit 229f3c6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions moai/export/local/video2d.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import functools
import logging
import os
import typing
from collections import defaultdict
from collections.abc import Callable

import ffmpegio
import numpy as np
import torch
from pytorch_lightning.callbacks import Callback

import moai.utils.color.colorize as mic
from moai.utils.arguments import ensure_choices, ensure_path

__all__ = ["Video2d"]
Expand Down Expand Up @@ -83,11 +80,15 @@ def close(self):
def __call__(
self,
images: np.ndarray, # TODO: add fps
fps: np.ndarray,
batch_idx: typing.Optional[int] = None,
) -> None:
if batch_idx == 0:
self.video_writer_lambda = functools.partial(
_create_video_writer, path=self.path, overwrite=self.overwrite
_create_video_writer,
path=self.path,
overwrite=self.overwrite,
fps=float(np.ceil(fps.squeeze())),
)
self.video_writers = defaultdict(self.video_writer_lambda)
for i, color in enumerate(images):
Expand Down

0 comments on commit 229f3c6

Please sign in to comment.