@@ -108,13 +108,19 @@ def process_ffmpeg_compose(data, job_id):
108108
109109 # Add inputs
110110 input_paths = []
111+ download_cache = {} # cache of url -> local_path
111112 for input_data in data ["inputs" ]:
112113 if "options" in input_data :
113114 for option in input_data ["options" ]:
114115 command .append (option ["option" ])
115116 if "argument" in option and option ["argument" ] is not None :
116117 command .append (str (option ["argument" ]))
117- input_path = download_file (input_data ["file_url" ], LOCAL_STORAGE_PATH )
118+ file_url = input_data ["file_url" ]
119+ if file_url in download_cache :
120+ input_path = download_cache [file_url ]
121+ else :
122+ input_path = download_file (file_url , LOCAL_STORAGE_PATH )
123+ download_cache [file_url ] = input_path
118124 input_paths .append (input_path )
119125 command .extend (["-i" , input_path ])
120126
@@ -174,4 +180,4 @@ def replace_subtitles_url(match):
174180 for output_filename in output_filenames :
175181 metadata .append (get_metadata (output_filename , data ["metadata" ], job_id ))
176182
177- return output_filenames , metadata
183+ return output_filenames , metadata
0 commit comments