@ -24,28 +24,29 @@ background_options = {
" https://www.youtube.com/watch?v=vw5L4xCPy9Q " ,
" https://www.youtube.com/watch?v=vw5L4xCPy9Q " ,
" bike-parkour-gta.mp4 " ,
" bike-parkour-gta.mp4 " ,
" Achy Gaming " ,
" Achy Gaming " ,
lambda t : ( ' center ' , 480 + t )
lambda t : ( " center " , 480 + t ) ,
) ,
) ,
" rocket-league " : ( # Rocket League
" rocket-league " : ( # Rocket League
" https://www.youtube.com/watch?v=2X9QGY__0II " ,
" https://www.youtube.com/watch?v=2X9QGY__0II " ,
" rocket_league.mp4 " ,
" rocket_league.mp4 " ,
" Orbital Gameplay " ,
" Orbital Gameplay " ,
" top "
" top " ,
) ,
) ,
" minecraft " : ( # Minecraft parkour
" minecraft " : ( # Minecraft parkour
" https://www.youtube.com/watch?v=n_Dv4JMiwK8 " ,
" https://www.youtube.com/watch?v=n_Dv4JMiwK8 " ,
" parkour.mp4 " ,
" parkour.mp4 " ,
" bbswitzer " ,
" bbswitzer " ,
" center "
" center " ,
) ,
) ,
" gta " : ( # GTA Stunt Race
" gta " : ( # GTA Stunt Race
" https://www.youtube.com/watch?v=qGa9kWREOnE " ,
" https://www.youtube.com/watch?v=qGa9kWREOnE " ,
" gta-stunt-race.mp4 " ,
" gta-stunt-race.mp4 " ,
" Achy Gaming " ,
" Achy Gaming " ,
lambda t : ( ' center ' , 480 + t )
lambda t : ( " center " , 480 + t ) ,
)
) ,
}
}
def get_start_and_end_times ( video_length : int , length_of_clip : int ) - > Tuple [ int , int ] :
def get_start_and_end_times ( video_length : int , length_of_clip : int ) - > Tuple [ int , int ] :
""" Generates a random interval of time to be used as the background of the video.
""" Generates a random interval of time to be used as the background of the video.
@ -59,10 +60,11 @@ def get_start_and_end_times(video_length: int, length_of_clip: int) -> Tuple[int
random_time = randrange ( 180 , int ( length_of_clip ) - int ( video_length ) )
random_time = randrange ( 180 , int ( length_of_clip ) - int ( video_length ) )
return random_time , random_time + video_length
return random_time , random_time + video_length
def get_background_config ( ) :
def get_background_config ( ) :
""" Fetch the background/s configuration """
""" Fetch the background/s configuration """
try :
try :
choice = str ( settings . config [ ' settings ' ] [ ' background_choice ' ] ) . casefold ( )
choice = str ( settings . config [ " settings " ] [ " background_choice " ] ) . casefold ( )
except AttributeError :
except AttributeError :
print_substep ( " No background selected. Picking random background ' " )
print_substep ( " No background selected. Picking random background ' " )
choice = None
choice = None
@ -90,8 +92,7 @@ def download_background(background_config: Tuple[str, str, str, Any]):
YouTube ( uri , on_progress_callback = on_progress ) . streams . filter ( res = " 1080p " ) . first ( ) . download (
YouTube ( uri , on_progress_callback = on_progress ) . streams . filter ( res = " 1080p " ) . first ( ) . download (
" assets/backgrounds " , filename = f " { credit } - { filename } "
" assets/backgrounds " , filename = f " { credit } - { filename } "
)
)
print_substep ( " Background videos downloaded successfully! 🎉 " ,
print_substep ( " Background videos downloaded successfully! 🎉 " , style = " bold green " )
style = " bold green " )
def chop_background_video ( background_config : Tuple [ str , str , str , Any ] , video_length : int ) :
def chop_background_video ( background_config : Tuple [ str , str , str , Any ] , video_length : int ) :
@ -107,8 +108,7 @@ def chop_background_video(background_config: Tuple[str, str, str, Any], video_le
background = VideoFileClip ( f " assets/backgrounds/ { choice } " )
background = VideoFileClip ( f " assets/backgrounds/ { choice } " )
start_time , end_time = get_start_and_end_times (
start_time , end_time = get_start_and_end_times ( video_length , background . duration )
video_length , background . duration )
try :
try :
ffmpeg_extract_subclip (
ffmpeg_extract_subclip (
f " assets/backgrounds/ { choice } " ,
f " assets/backgrounds/ { choice } " ,