mirror of
https://github.com/taigrr/jumpcutter
synced 2025-01-18 04:43:13 -08:00
Merge pull request #17 from allisonChilton/master
Add parser option to use youtube url as input
This commit is contained in:
commit
136df102fe
@ -10,6 +10,13 @@ import math
|
|||||||
from shutil import copyfile, rmtree
|
from shutil import copyfile, rmtree
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
|
from pytube import YouTube
|
||||||
|
|
||||||
|
def downloadFile(url):
|
||||||
|
name = YouTube(url).streams.first().download()
|
||||||
|
newname = name.replace(' ','_')
|
||||||
|
os.rename(name,newname)
|
||||||
|
return newname
|
||||||
|
|
||||||
def getMaxVolume(s):
|
def getMaxVolume(s):
|
||||||
maxv = float(np.max(s))
|
maxv = float(np.max(s))
|
||||||
@ -47,6 +54,7 @@ def deletePath(s): # Dangerous! Watch out!
|
|||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Modifies a video file to play at different speeds when there is sound vs. silence.')
|
parser = argparse.ArgumentParser(description='Modifies a video file to play at different speeds when there is sound vs. silence.')
|
||||||
parser.add_argument('--input_file', type=str, help='the video file you want modified')
|
parser.add_argument('--input_file', type=str, help='the video file you want modified')
|
||||||
|
parser.add_argument('--url', type=str, help='A youtube url to download and process')
|
||||||
parser.add_argument('--output_file', type=str, default="", help="the output file. (optional. if not included, it'll just modify the input file name)")
|
parser.add_argument('--output_file', type=str, default="", help="the output file. (optional. if not included, it'll just modify the input file name)")
|
||||||
parser.add_argument('--silent_threshold', type=float, default=0.03, help="the volume amount that frames' audio needs to surpass to be consider \"sounded\". It ranges from 0 (silence) to 1 (max volume)")
|
parser.add_argument('--silent_threshold', type=float, default=0.03, help="the volume amount that frames' audio needs to surpass to be consider \"sounded\". It ranges from 0 (silence) to 1 (max volume)")
|
||||||
parser.add_argument('--sounded_speed', type=float, default=1.00, help="the speed that sounded (spoken) frames should be played at. Typically 1.")
|
parser.add_argument('--sounded_speed', type=float, default=1.00, help="the speed that sounded (spoken) frames should be played at. Typically 1.")
|
||||||
@ -58,19 +66,26 @@ parser.add_argument('--frame_quality', type=int, default=3, help="quality of fra
|
|||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
frameRate = args.frame_rate
|
frameRate = args.frame_rate
|
||||||
SAMPLE_RATE = args.sample_rate
|
SAMPLE_RATE = args.sample_rate
|
||||||
SILENT_THRESHOLD = args.silent_threshold
|
SILENT_THRESHOLD = args.silent_threshold
|
||||||
FRAME_SPREADAGE = args.frame_margin
|
FRAME_SPREADAGE = args.frame_margin
|
||||||
NEW_SPEED = [args.silent_speed, args.sounded_speed]
|
NEW_SPEED = [args.silent_speed, args.sounded_speed]
|
||||||
INPUT_FILE = args.input_file
|
if args.url != None:
|
||||||
|
INPUT_FILE = downloadFile(args.url)
|
||||||
|
else:
|
||||||
|
INPUT_FILE = args.input_file
|
||||||
|
URL = args.url
|
||||||
FRAME_QUALITY = args.frame_quality
|
FRAME_QUALITY = args.frame_quality
|
||||||
|
|
||||||
assert INPUT_FILE != None, "why u put no input file, that dum"
|
assert INPUT_FILE != None , "why u put no input file, that dum"
|
||||||
|
|
||||||
OUTPUT_FILE = inputToOutputFilename(INPUT_FILE)
|
|
||||||
if len(args.output_file) >= 1:
|
if len(args.output_file) >= 1:
|
||||||
OUTPUT_FILE = args.output_file
|
OUTPUT_FILE = args.output_file
|
||||||
|
else:
|
||||||
|
OUTPUT_FILE = inputToOutputFilename(INPUT_FILE)
|
||||||
|
|
||||||
TEMP_FOLDER = "TEMP"
|
TEMP_FOLDER = "TEMP"
|
||||||
AUDIO_FADE_ENVELOPE_SIZE = 400 # smooth out transitiion's audio by quickly fading in/out (arbitrary magic number whatever)
|
AUDIO_FADE_ENVELOPE_SIZE = 400 # smooth out transitiion's audio by quickly fading in/out (arbitrary magic number whatever)
|
||||||
|
@ -2,3 +2,4 @@ Pillow
|
|||||||
audiotsm
|
audiotsm
|
||||||
scipy
|
scipy
|
||||||
numpy
|
numpy
|
||||||
|
pytube
|
||||||
|
Loading…
x
Reference in New Issue
Block a user