Skip to content

Instantly share code, notes, and snippets.

@GarryLai
Last active March 24, 2025 14:28
Show Gist options
  • Save GarryLai/27d9fcc08ab02c00f8f1d0acbc5b85ee to your computer and use it in GitHub Desktop.
Save GarryLai/27d9fcc08ab02c00f8f1d0acbc5b85ee to your computer and use it in GitHub Desktop.
Agisoft Metashape videos batch import
#
# Metashape videos batch import v1.0
# Author: Garry Lai
# Usage: "Tools" --> "Run script"
#
import Metashape
doc = Metashape.app.document
chunk = doc.chunk
files = Metashape.app.getOpenFileNames('Import Videos', filter='All Formats (*.avi *.flv *.mov *.mp4 *.wmv);;All Files (*.*)')
print('Files to import:', files)
out_path = Metashape.app.getExistingDirectory('Output folder')
if out_path == '':
Metashape.app.messageBox("Aborted by user")
files = []
for file in files:
filename = file.split('\\')[-1].split('/')[-1].split('.')[0]
print('Import:', filename)
chunk.importVideo(path=file, image_path=f"{out_path}/{filename}-{{filenum}}.png", frame_step=Metashape.FrameStep.SmallFrameStep)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment