syncng
This commit is contained in:
Binary file not shown.
@@ -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.
|
||||||
@@ -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()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
moviepy
|
||||||
@@ -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()
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
moviepy
|
||||||
Reference in New Issue
Block a user