MCPcopy
hub / github.com/diffgram/diffgram / load

Method load

walrus/methods/video/video.py:119–376  ·  view source on GitHub ↗

Convert to .mp4 format if needed Upload .mp4 video Process each frame Arguments video_file_name, String, complete file path including directory, filename, and extension original_filename, String extension, String, includes ".", i

(self,
             video_file_name,
             original_filename,
             extension,
             input: Input,
             directory_id = None)

Source from the content-addressed store, hash-verified

117
118
119 def load(self,
120 video_file_name,
121 original_filename,
122 extension,
123 input: Input,
124 directory_id = None):
125 """
126
127 Convert to .mp4 format if needed
128 Upload .mp4 video
129 Process each frame
130
131 Arguments
132 video_file_name, String, complete file path including directory, filename, and extension
133 original_filename, String
134 extension, String, includes ".", ie ".mp4"
135
136 Returns
137 None
138 """
139 check_and_wait_for_memory(memory_limit_float=85.0)
140
141 logger.info(f"Reading video data for {input.id} - {video_file_name}")
142 try:
143
144 clip = moviepy_editor.VideoFileClip(video_file_name)
145 input.status = "loaded_video"
146 input.time_loaded_video = datetime.datetime.utcnow()
147 input.percent_complete = 20.0
148 self.try_to_commit()
149
150 except Exception as exception:
151 input.status = "failed"
152 input.status_text = "Could not load video. Try again, try a different format or contact us."
153 # only for internal use
154 # could look at storing in DB later or Using event logging.
155 logger.error('Could not load video. Try again, try a different format or contact us. Exception: {}'.format(
156 str(exception)))
157 return None
158
159 # https://stackoverflow.com/questions/43966523/getting-oserror-winerror-6-the-handle-is-invalid-in-videofileclip-function
160 clip.reader.close()
161 # Audio thing here too still doesn't seem to fix it...
162 # clip.audio.reader.close_proc()
163
164 # fps handling
165 fps = self.project.settings_input_video_fps
166
167 if fps is None:
168 fps = 5
169
170 if fps < 0 or fps > 120:
171 input.status = "failed"
172 input.status_text = f"Invalid fps setting of {fps}"
173 return None
174
175 original_fps = clip.fps # Cache, since it will change
176

Callers 3

process_videoMethod · 0.95
coco_transform.pyFile · 0.45

Calls 11

try_to_commitMethod · 0.95
__prepare_sequencesMethod · 0.95
upload_video_fileMethod · 0.95
add_frame_to_queueMethod · 0.95
resize_videoFunction · 0.85
parent_inputMethod · 0.80
newMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected