Skip to content

Instantly share code, notes, and snippets.

View JupyterJones's full-sized avatar

Jack Northrup JupyterJones

View GitHub Profile
@JupyterJones
JupyterJones / zoomin.py
Created October 1, 2023 16:31
Flask Zoom and Image to video
#!/home/jack/Desktop/FlaskAppArchitect_Flask_App_Creator/env/bin/python3
from flask import Flask, request, render_template, redirect, url_for, flash, send_from_directory
import os
import subprocess
import random
import uuid
import shutil
from werkzeug.utils import secure_filename
import glob
import logging
@JupyterJones
JupyterJones / app.py
Created August 31, 2023 22:39
A self editing flask app capable of creating other flask apps
#!/home/jack/Desktop/StoryMaker/env/bin/python
from moviepy.editor import *
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, Response, flash, request, session,jsonify
from flask import send_file, g
import os
import pygame
from gtts import gTTS
import cv2
import dlib
import numpy as np
@JupyterJones
JupyterJones / feather.py
Created August 26, 2023 11:59
Use flask to feather transparent pngs
from flask import Flask, render_template, request
import os
import numpy as np
import cv2
import datetime
import matplotlib.pyplot as plt
from werkzeug.utils import secure_filename
import logging
app = Flask(__name__)
@JupyterJones
JupyterJones / SuperEffect.sh
Created August 22, 2023 00:35
This script processes a sequence of images into a video, applies video effects, # adds background music, and generates a final video output
#!/bin/bash
ffmpeg -framerate 17 -i %05d.jpg -c:v libx265 -r 30 -pix_fmt yuv420p -y start.mp4
ls "$(pwd)/start.mp4"
# Print instructions for the user
echo "This script will process a video file located in the current directory."
echo "Please ensure that the 'start.mp4' file exists in this directory before proceeding."
echo "Press ENTER to continue, or CTRL+C to cancel."
read
@JupyterJones
JupyterJones / app.py
Created August 19, 2023 15:24
Flask creates mp4 backgrounds using images from thumbnail cache
#!/home/jack/Desktop/StoryMaker/env/bin/python
from flask import Flask, render_template, request, redirect, url_for, send_from_directory, Response,flash
from flask import send_file, make_response,g
import os
import subprocess
import shutil
import logging
import random
from random import randint
import glob
@JupyterJones
JupyterJones / Generate_random_58seconds.py
Created August 6, 2023 02:13
Gets a random song from an mp3 directory. gets a random 58 seconds from that mp3 and save with a unique using uuid as an .mp3
from moviepy.editor import AudioFileClip
import random
from scipy.io import wavfile
import uuid
import glob
import random
# Function to find a random song in the Music directory
def music():
MUSIC = random.choice(glob.glob("/home/jack/Desktop/HDD500/collections/Music/*.mp3"))
return MUSIC
@JupyterJones
JupyterJones / music_fade.py
Created August 5, 2023 20:48
Use Moviepy to fade in and fade out music on mp4
from moviepy.editor import *
from moviepy.audio.fx.all import audio_fadein
from MUSIC import music
# Load video and audio clips
video_clip = VideoFileClip("/home/jack/Desktop/StoryMaker/static/images/Elektra-Weapons/Final_End.mp4")
audio_clip = AudioFileClip(music())
# Ensure the audio clip is the same duration as the video
if audio_clip.duration > video_clip.duration:
@JupyterJones
JupyterJones / merge_random_mp4.py
Created August 4, 2023 23:56
This script selects 30 random videos from the path entered in this case "~/Desktop/StoryMaker/VIDEOS" and merges a random .5 seconds from each video into one video.
import os
import random
import shutil
import uuid
from moviepy.editor import VideoFileClip, concatenate_videoclips
def get_random_video_clips(dir_path, num_clips=30, clip_duration=1, target_size=(512, 768), default_fps=30):
video_files = []
for root, dirs, files in os.walk(dir_path):
@JupyterJones
JupyterJones / quantize_to_palette.py
Created August 1, 2023 09:19
quantize images to a specific palette Python cv2
import cv2
import numpy as np
from moviepy.editor import VideoFileClip
from sklearn.cluster import KMeans
# Define your own color palette as an array of RGB values
palette = np.array([[255, 0, 0], # Red
[0, 255, 0], # Green
[0, 0, 255], # Blue
[255, 255, 0], # Yellow
[255, 0, 255], # Magenta
@JupyterJones
JupyterJones / TUBEvid.py
Created June 23, 2023 15:28
creates a video from shuffled video files in a directory
import random
import glob
import subprocess
from PIL import Image
from datetime import datetime
def tubevid(DIR):
image_files = glob.glob(DIR + "*.jpg")
random.shuffle(image_files)
# Determine the dimensions of the first image