This commit introduces the VideoEditor class in editor.py, encapsulating various video editing features such as playback control, cropping, zooming, and motion tracking. The class manages video file handling, state saving/loading, and user interactions, providing a comprehensive interface for video editing. Additionally, it includes configuration constants for timeline and progress bar settings, improving the overall user experience and maintainability of the codebase.
60 lines
1.7 KiB
Python
60 lines
1.7 KiB
Python
import os
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Allow running this file directly: `uv run croppa/main.py ...`
|
|
if (__package__ is None or __package__ == "") and "croppa" not in sys.modules:
|
|
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
|
import cv2
|
|
import argparse
|
|
import numpy as np
|
|
from pathlib import Path
|
|
from typing import List, Dict, Tuple, Optional
|
|
import time
|
|
import re
|
|
import json
|
|
import threading
|
|
import queue
|
|
import subprocess
|
|
from croppa.capture import Cv2BufferedCap
|
|
from croppa.tracking import MotionTracker
|
|
from croppa.utils import get_active_window_title
|
|
from croppa.project_view import ProjectView
|
|
from croppa.editor import VideoEditor
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="Fast Media Editor - Crop, Zoom, and Edit videos and images"
|
|
)
|
|
parser.add_argument(
|
|
"media", help="Path to media file or directory containing videos/images"
|
|
)
|
|
|
|
try:
|
|
args = parser.parse_args()
|
|
except SystemExit:
|
|
# If launched from context menu without arguments, this might fail
|
|
input("Argument parsing failed. Press Enter to exit...")
|
|
return
|
|
|
|
if not os.path.exists(args.media):
|
|
error_msg = f"Error: {args.media} does not exist"
|
|
print(error_msg)
|
|
input("Press Enter to exit...") # Keep window open in context menu
|
|
sys.exit(1)
|
|
|
|
try:
|
|
editor = VideoEditor(args.media)
|
|
editor.run()
|
|
except Exception as e:
|
|
error_msg = f"Error initializing media editor: {e}"
|
|
print(error_msg)
|
|
import traceback
|
|
traceback.print_exc() # Full error trace for debugging
|
|
input("Press Enter to exit...") # Keep window open in context menu
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|