程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python video audio merge function related, FL_ time(),AudioFileClip(). duration

編輯:Python
The phenomenon and background of the problem

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 )

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved