0

此代码下载视频并将其转换为 mp3 文件。但是,mp3 音频将比普通视频长 2 倍。我怎么解决这个问题?

import pafy
import os
import moviepy.editor as mp


print "[+] Welcome to Youtube downloader."
download_url = raw_input("URL :")

video = pafy.new(download_url)
best = video.streams
file_name = video.streams[0]
print file_name

directory = "downloaded-music"
if not os.path.exists(directory):
    os.makedirs(directory)
x = file_name.download(filepath = directory)

clip = mp.VideoFileClip(x)
print clip.size
clip.audio.write_audiofile(x + ".mp3")

os.remove(x)
4

1 回答 1

0

是“clip.size”的值是实际值的两倍,还是文件的实际长度?

于 2016-08-08T10:22:12.770 回答