ffmpeg 切分音频视频,统计音频时长

# audio duration
    def make_duration(file_path):
        result = sp.run(["ffprobe", "-v", "error", "-show_entries",
                         "format=duration", "-of",
                         "default=noprint_wrappers=1:nokey=1", file_path], 
                         stdout=sp.PIPE,
                         stderr=sp.STDOUT)
        return float(result.stdout)

# cut video and audio
cmd_split_line = 'ffmpeg -loglevel quiet -ss {} -to {} -accurate_seek -i "{}" "{}" -y'.format(start_time, end_time, self.file_path, dst_mp4_path)
sp.check_call(cmd_split_line, shell=True, stderr=open(os.devnull, 'w'))

posted @ 2023-08-23 16:27  不能说的秘密  阅读(170)  评论(0编辑  收藏  举报