Recently, I imitated a frequency recording function and encountered a suitable one from many codes , But some of them don't understand , I don't know if my understanding is correct . I checked fl_time() The first parameter of , According to my code, it should be 1/ration Speed up , But he did synchronize the video content with the matching sound at that time , I don't understand this question , Secondly, the second parameter I find is whether to write "audio" still "video" There seems to be no difference , Please help me , I don't understand this ratio The meaning of . And I set a recording time, for example 30 second ,video.duration Take it input() It's almost 30 second , however audio.duration Take it input() Come out only 30 About half a second , What's the reason for this ?
audio = AudioFileClip(self.file_path + ".wav") # Audio loading video = VideoFileClip(self.file_path + ".avi") # Loading of video ratio = audio.duration / video.duration video = video.fl_time(lambda t: t/ratio , # With 1/ration Speed up , Sync video action and sound apply_to=["audio"] # Audio acting on clips # The third parameter defaults to False, It means to modify duration ).set_end( audio.duration # Set the end time of playback in the composite clip )