Skip to content

Commit c8d5075

Browse files
Avoid uploading partial video files
1 parent 4926449 commit c8d5075

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

local_video_processor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,20 +205,25 @@ async def extract_clip(self, match_info: Mapping[str, object]) -> Path | None:
205205
output_path = self.output_dir / f"{match_name}_{counter}.mp4"
206206
counter += 1
207207

208+
# Write to .partial file during encoding, then rename when done
209+
partial_path = output_path.parent / (output_path.name + '.partial')
208210
logger.info(f"Extracting clip: {clip_start:.1f}s + {clip_duration:.1f}s -> {output_path}")
209211

210212
success = await self.extract_clip_ffmpeg(
211213
input_path=recording_path,
212-
output_path=output_path,
214+
output_path=partial_path,
213215
start_time=clip_start,
214216
duration=clip_duration
215217
)
216218

217-
if success and output_path.exists():
219+
if success and partial_path.exists():
220+
_ = partial_path.rename(output_path)
218221
logger.info(f"✅ Successfully created clip: {output_path}")
219222
return output_path
220223
else:
221224
logger.error(f"❌ Failed to create clip: {output_path}")
225+
if partial_path.exists():
226+
partial_path.unlink()
222227
return None
223228

224229
except Exception as e:
@@ -237,6 +242,7 @@ async def extract_clip_ffmpeg(self, input_path: Path, output_path: Path,
237242
'-c', 'copy', # Copy streams without re-encoding for speed
238243
'-threads', '1', # Limit to single thread to minimize impact on stream
239244
'-avoid_negative_ts', 'make_zero',
245+
'-f', 'mp4',
240246
str(output_path)
241247
]
242248

matchbox-sync.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def run_rsync(config: dict[str, object]) -> bool:
8989
'rsync',
9090
'-avz',
9191
'--checksum',
92+
'--exclude', '*.partial',
9293
str(source_path) + '/', # Trailing slash to sync contents
9394
rsync_url
9495
]

matchbox.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,7 @@ def _run_rsync(self) -> bool:
13191319
get_rsync_path(),
13201320
'-avz',
13211321
'--checksum',
1322+
'--exclude', '*.partial',
13221323
source_arg,
13231324
rsync_url
13241325
]

0 commit comments

Comments
 (0)