diff --git a/DownloaderWebApp/start.sh b/DownloaderWebApp/start.sh new file mode 100755 index 0000000..b965ac7 --- /dev/null +++ b/DownloaderWebApp/start.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Navigate to the script's directory +cd "$(dirname "$0")" + +# Check for virtual environment and activate if found +if [ -d "venv" ]; then + source venv/bin/activate +elif [ -d ".venv" ]; then + source .venv/bin/activate +fi + +echo "Starting DownloaderWebApp..." +python3 main.py & +PID=$! +echo $PID > app.pid +echo "Application started with PID: $PID" diff --git a/DownloaderWebApp/stop.sh b/DownloaderWebApp/stop.sh new file mode 100755 index 0000000..84ef1b0 --- /dev/null +++ b/DownloaderWebApp/stop.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Navigate to the script's directory +cd "$(dirname "$0")" + +if [ -f "app.pid" ]; then + PID=$(cat app.pid) + if ps -p $PID > /dev/null; then + echo "Stopping app (PID $PID)..." + kill $PID + rm app.pid + echo "Stopped." + else + echo "PID file found ($PID) but process is not running. Removing stale PID file." + rm app.pid + fi +else + echo "No PID file found. Trying to find process by name..." + pkill -f "python3 main.py" + if [ $? -eq 0 ]; then + echo "Stopped via process name." + else + echo "No running process found." + fi +fi diff --git a/video_merge/__pycache__/merge_videos.cpython-313.pyc b/video_merge/__pycache__/merge_videos.cpython-313.pyc new file mode 100644 index 0000000..6861615 Binary files /dev/null and b/video_merge/__pycache__/merge_videos.cpython-313.pyc differ diff --git a/video_merge/context/README.md b/video_merge/context/README.md new file mode 100644 index 0000000..9b32600 --- /dev/null +++ b/video_merge/context/README.md @@ -0,0 +1,28 @@ +# Video Merge Project Context + +This folder contains the necessary files to resume the Video Merge session. + +## Contents + +- `merge_videos.py`: The main Python script to merge video files. +- `requirements.txt`: List of Python dependencies. + +## Setup Instructions + +1. **Prerequisites**: Ensure Python 3 is installed on the new machine. +2. **Install Dependencies**: + Open a terminal in this folder and run: + ```bash + pip install -r requirements.txt + ``` + *Note: The script uses `moviepy`. If you encounter issues with ffmpeg, ensure it is installed on your system or that the `imageio-ffmpeg` package was installed successfully with moviepy.* + +## Running the Script + +To start the video merger tool: + +```bash +python3 merge_videos.py +``` + +Follow the on-screen prompts to input video file paths and the desired output filename. diff --git a/video_merge/context/merge_videos.py b/video_merge/context/merge_videos.py new file mode 100644 index 0000000..97e47b0 --- /dev/null +++ b/video_merge/context/merge_videos.py @@ -0,0 +1,96 @@ +import os +import sys + +def get_file_paths(): + """Prompts the user for video file paths.""" + file_paths = [] + print("Enter the paths to the video files you want to merge.") + print("Type 'done' when you are finished.") + + while True: + user_input = input(f"File path #{len(file_paths) + 1}: ").strip() + + if user_input.lower() == 'done': + if len(file_paths) < 2: + print("Please provide at least two video files to merge.") + continue + break + + if not user_input: + continue + + # Remove quotes if the user pasted a path with quotes + user_input = user_input.strip('"').strip("'") + + if os.path.exists(user_input) and os.path.isfile(user_input): + file_paths.append(user_input) + print(f"Added: {user_input}") + else: + print(f"Error: File not found at '{user_input}'. Please try again.") + + return file_paths + +def main(): + print("--- Video Merger Tool ---") + + try: + # Check if moviepy is installed + try: + from moviepy.editor import VideoFileClip, concatenate_videoclips + except ImportError: + print("Error: 'moviepy' library is not installed.") + print("Please run: pip install -r requirements.txt") + return + + video_files = get_file_paths() + + output_filename = input("Enter the output file name (e.g., merged_video.mp4): ").strip() + if not output_filename: + output_filename = "merged_output.mp4" + print(f"No name provided. Using default: {output_filename}") + + if not output_filename.lower().endswith(".mp4"): + output_filename += ".mp4" + print(f"Added extension. Output will be: {output_filename}") + + print("\nProcessing videos... This may take a while depending on file size.") + + clips = [] + try: + for path in video_files: + print(f"Loading {path}...") + clip = VideoFileClip(path) + clips.append(clip) + + print("Concatenating clips...") + final_clip = concatenate_videoclips(clips) + + print(f"Writing to {output_filename} (H.264 / AAC)...") + final_clip.write_videofile( + output_filename, + codec='libx264', + audio_codec='aac', + temp_audiofile='temp-audio.m4a', + remove_temp=True, + logger='bar' + ) + + print(f"\nSuccess! Merged video saved to: {os.path.abspath(output_filename)}") + + except Exception as e: + print(f"\nAn error occurred during processing: {e}") + finally: + # Clean up resources + for clip in clips: + try: + clip.close() + except: + pass + + except KeyboardInterrupt: + print("\nOperation cancelled by user.") + except Exception as e: + print(f"\nUnexpected error: {e}") + +if __name__ == "__main__": + main() diff --git a/video_merge/context/requirements.txt b/video_merge/context/requirements.txt new file mode 100644 index 0000000..a384113 --- /dev/null +++ b/video_merge/context/requirements.txt @@ -0,0 +1 @@ +moviepy diff --git a/video_merge/merge_videos.py b/video_merge/merge_videos.py new file mode 100644 index 0000000..97e47b0 --- /dev/null +++ b/video_merge/merge_videos.py @@ -0,0 +1,96 @@ +import os +import sys + +def get_file_paths(): + """Prompts the user for video file paths.""" + file_paths = [] + print("Enter the paths to the video files you want to merge.") + print("Type 'done' when you are finished.") + + while True: + user_input = input(f"File path #{len(file_paths) + 1}: ").strip() + + if user_input.lower() == 'done': + if len(file_paths) < 2: + print("Please provide at least two video files to merge.") + continue + break + + if not user_input: + continue + + # Remove quotes if the user pasted a path with quotes + user_input = user_input.strip('"').strip("'") + + if os.path.exists(user_input) and os.path.isfile(user_input): + file_paths.append(user_input) + print(f"Added: {user_input}") + else: + print(f"Error: File not found at '{user_input}'. Please try again.") + + return file_paths + +def main(): + print("--- Video Merger Tool ---") + + try: + # Check if moviepy is installed + try: + from moviepy.editor import VideoFileClip, concatenate_videoclips + except ImportError: + print("Error: 'moviepy' library is not installed.") + print("Please run: pip install -r requirements.txt") + return + + video_files = get_file_paths() + + output_filename = input("Enter the output file name (e.g., merged_video.mp4): ").strip() + if not output_filename: + output_filename = "merged_output.mp4" + print(f"No name provided. Using default: {output_filename}") + + if not output_filename.lower().endswith(".mp4"): + output_filename += ".mp4" + print(f"Added extension. Output will be: {output_filename}") + + print("\nProcessing videos... This may take a while depending on file size.") + + clips = [] + try: + for path in video_files: + print(f"Loading {path}...") + clip = VideoFileClip(path) + clips.append(clip) + + print("Concatenating clips...") + final_clip = concatenate_videoclips(clips) + + print(f"Writing to {output_filename} (H.264 / AAC)...") + final_clip.write_videofile( + output_filename, + codec='libx264', + audio_codec='aac', + temp_audiofile='temp-audio.m4a', + remove_temp=True, + logger='bar' + ) + + print(f"\nSuccess! Merged video saved to: {os.path.abspath(output_filename)}") + + except Exception as e: + print(f"\nAn error occurred during processing: {e}") + finally: + # Clean up resources + for clip in clips: + try: + clip.close() + except: + pass + + except KeyboardInterrupt: + print("\nOperation cancelled by user.") + except Exception as e: + print(f"\nUnexpected error: {e}") + +if __name__ == "__main__": + main() diff --git a/video_merge/requirements.txt b/video_merge/requirements.txt new file mode 100644 index 0000000..a384113 --- /dev/null +++ b/video_merge/requirements.txt @@ -0,0 +1 @@ +moviepy