Skip to content

new node generateVideo from sfmData#3

Open
servantftransperfect wants to merge 1 commit intomasterfrom
dev/newCommand
Open

new node generateVideo from sfmData#3
servantftransperfect wants to merge 1 commit intomasterfrom
dev/newCommand

Conversation

@servantftransperfect
Copy link
Contributor

Generate a new node to which will generate a video given a sfmData.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Meshroom “Video Utils” node intended to generate a video from an SfMData by ordering views via frameId.

Changes:

  • Introduces a new GenerateVideo command-line node that reads an SfMData and creates a sequential image set via symlinks.
  • Builds an ffmpeg command to encode those frames into an MP4 in the node cache.
  • Adds a root .gitignore entry for __pycache__.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated 6 comments.

File Description
meshroom/videoUtils/generateVideo.py New node that loads SfMData views, creates sequential symlinks, and runs ffmpeg to produce a video.
.gitignore Ignores Python __pycache__ artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +52 to +54
import logging
logging.getLogger().setLevel(chunk.node.verboseLevel.value.upper())

Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the root logger level inside a node (logging.getLogger().setLevel(...)) can have side effects on unrelated logging in the same process. Prefer configuring a module-specific logger (e.g. logging.getLogger(__name__)) or using Meshroom’s standard logging facilities for nodes if available.

Copilot uses AI. Check for mistakes.
Comment on lines 17 to 23
desc.FloatParam(
name="frameRate",
label="Camera Frame Rate",
description="Define the camera's Frames per second.",
value=24.0,
range=(1.0, 60.0, 1.0),
),
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameter naming is inconsistent with the existing nodes in meshroom/videoUtils (framerate is used elsewhere). Consider renaming frameRate to framerate for consistency and to make scripting/graph reuse more predictable.

Copilot uses AI. Check for mistakes.
link.symlink_to(target)
pos = pos + 1

self.commandLine = f"ffmpeg -framerate 24 -start_number 0 -i %012d{suffix} -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" -c:v libx264 -pix_fmt yuv420p {chunk.node.outputVideo.value}"
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The frameRate input is not used: the ffmpeg command hardcodes -framerate 24. Use the node parameter value for -framerate so the UI control actually affects the generated video. Also consider adding -y (as in other videoUtils nodes) to avoid failing on reruns when the output file already exists.

Suggested change
self.commandLine = f"ffmpeg -framerate 24 -start_number 0 -i %012d{suffix} -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" -c:v libx264 -pix_fmt yuv420p {chunk.node.outputVideo.value}"
self.commandLine = f"ffmpeg -y -framerate {chunk.node.frameRate.value} -start_number 0 -i %012d{suffix} -vf \"scale=trunc(iw/2)*2:trunc(ih/2)*2\" -c:v libx264 -pix_fmt yuv420p {chunk.node.outputVideo.value}"

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +101
# Create a link using a sequential order
link = intermediate_directory / f"{pos:012d}{suffix}"

# Force symlink creation
if link.exists() or link.is_symlink():
link.unlink()

# Create symbolic link
link.symlink_to(target)
pos = pos + 1
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop only overwrites links from 0..N-1; if the node cache is reused and a later run has fewer frames than a previous run, stale symlinks beyond pos will remain and ffmpeg will silently include old frames. Clear previously generated links (or generate them in a dedicated subdirectory that you recreate/clean each run) before creating the new sequence.

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +73


Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the SfMData contains zero views, suffix stays empty and no links are created, but the node still builds an ffmpeg command that cannot work. Add an explicit check after loading/views extraction to fail fast with a clear error when no views/images are found.

Suggested change
# fail fast if no views/images were found
if not viewsPerFrameId:
logging.error("No views/images found in the input SfMData.")
raise RuntimeError()

Copilot uses AI. Check for mistakes.
Comment on lines +62 to +63
logging.error("Cannot open input")
raise RuntimeError()
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error handling here drops important context: it logs a generic message and raises RuntimeError() without any message/path, which makes failures hard to debug. Include the input filepath in the log/exception and raise with a descriptive message (or rethrow a more specific exception) so the UI/logs show actionable info.

Suggested change
logging.error("Cannot open input")
raise RuntimeError()
logging.error("Cannot open input sfmData file: %s", chunk.node.input.value)
raise RuntimeError(f"Cannot open input sfmData file: {chunk.node.input.value}")

Copilot uses AI. Check for mistakes.
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 this pull request may close these issues.

2 participants