Datasets:
Tags:
Not-For-All-Audiences
Upload Mp4 merge.ipynb
Browse files- Mp4 merge.ipynb +1 -0
Mp4 merge.ipynb
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"cells":[{"cell_type":"code","source":["# Install moviepy if not already installed\n","!pip install moviepy\n","\n","from moviepy.editor import VideoFileClip, concatenate_videoclips, ColorClip\n","import os\n","\n","# Function to create a fade-to-black clip\n","def create_fade_clip(duration=1.24, fps=24):\n"," return ColorClip(size=(1920, 1080), color=(0, 0, 0), duration=duration).set_fps(fps)\n","\n","# Path to your MP4 files\n","video_files = ['pumpkin5.mp4', 'pumpkin6.mp4', 'pumpkin7.mp4', 'pumpkin89.mp4', 'pumpkin10.mp4']\n","\n","# Load video clips\n","clips = [VideoFileClip(file) for file in video_files]\n","\n","# Duration of fade transition (in seconds)\n","fade_duration = 1.24\n","\n","# Create a black clip for fade transitions\n","fade_clip = create_fade_clip(duration=fade_duration)\n","\n","# Apply fade-in from the first frame and fade-out to the end of each clip\n","processed_clips = []\n","for clip in clips:\n"," # Apply fade-in starting from the first frame\n"," clip = clip.fadein(fade_duration)\n"," # Apply fade-out at the end\n"," clip = clip.fadeout(fade_duration)\n"," processed_clips.append(clip)\n","\n","# Create the sequence: start with fade-in black, then clips with fade transitions, end with fade-out black\n","final_sequence = [fade_clip] # Start with fade-in from black\n","for i, clip in enumerate(processed_clips):\n"," final_sequence.append(clip)\n"," if i < len(processed_clips) - 1:\n"," final_sequence.append(fade_clip) # Add fade-to-black between clips\n","final_sequence.append(fade_clip) # End with fade-to-black\n","\n","# Concatenate all clips\n","final_video = concatenate_videoclips(final_sequence, method=\"compose\")\n","\n","# Ensure audio fades for the entire video\n","final_video = final_video.audio_fadein(fade_duration).audio_fadeout(fade_duration)\n","\n","# Save the final video\n","output_path = \"output_video.mp4\"\n","final_video.write_videofile(output_path, codec=\"libx264\", audio_codec=\"aac\")\n","\n","# Close clips to free memory\n","for clip in clips:\n"," clip.close()\n","final_video.close()\n","\n","print(f\"Video saved as {output_path}\")"],"metadata":{"id":"PcUo5tfD01VJ"},"execution_count":null,"outputs":[]}],"metadata":{"colab":{"provenance":[{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/Drive to WebP.ipynb","timestamp":1761335712919},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/Drive to WebP.ipynb","timestamp":1760993725927},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1760450712160},{"file_id":"https://huggingface.co/datasets/codeShare/lora-training-data/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1756712618300},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1747490904984},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1740037333374},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1736477078136},{"file_id":"https://huggingface.co/codeShare/JupyterNotebooks/blob/main/YT-playlist-to-mp3.ipynb","timestamp":1725365086834}]},"kernelspec":{"display_name":"Python 3","name":"python3"},"language_info":{"name":"python"}},"nbformat":4,"nbformat_minor":0}
|