Sub_font_name = "/System/Library/Fonts/SFNSText.ttf", # a text file that contains the description of the tracks that constitute the videoįunc_sort_audio_files = default_func_sort_audio_files, # Descriptions and subtitles are obtained using 'func_get_audio_description_subtitles' # Audio tracks are sorted using 'func_sort_audio_files' # While an audio track is being played, one image, with the subtitles, is shown. # All images with given extensions from the same directory are fetched. It creates the video with all audio files of a given directory Os.path.basename(image_filename) + '_with_subs.png') # composite the two images together and save Sub_bg_top = height - len(subtitles) * 2 * font.size - sub_indent_xĭraw.rectangle(((0, sub_bg_top), (sub_bg_right, height)), fill = sub_bg_colour)ĭraw.text((sub_indent_x, sub_indent_y), subtitle, sub_colour, font = font) # make a blank completely transparent image for the rectangle # Returns the filename of the resulting image (including the path) # Resize image, add subtitles and save it. Return (os.path.dirname(audio_name), track_nb, os.path.basename(audio_name)) # then the number of the track, then the name of the fileĭef default_func_sort_audio_files(audio_name):Īudio_mediainfo = (audio_name).get('TAG', None) # Score function for default audio sorting: directory containing the file, Result += glob.glob(path_pattern, recursive=True) Path_pattern = os.path.join(directory_name, '**', '*.' + extension) # get filenames with given extensions from a given directory and all directories inside itĭef get_filenames_with_extensions_recursively(directory_name, extensions): Import cv2, pydub, PIL # these packages need to be installed The code looks a bit naive, but introducing more complex structures is probably an overkill given the simplicity of the task. I am creating a silent video using OpenCV, combining MP3s using pydub, then put audio and video together using ffmpeg. It is intended for personal use, so no input error checks. This is a quick script that helps me to convert MP3 files from my CDs into videos I can upload on YouTube.
0 Comments
Leave a Reply. |