python - 在python中将视频转换为音频
问题描述
我尝试制作一个转换器应用程序,它可以从 youtube 下载 .3gpp 格式的视频并将其转换为 mp3,但我有一些关于权限的问题,我现在真的不关心 windows 和 python 权限。
import pytube
import moviepy.editor as mp
while True:
url = input("Video url: ")
print("Downloading video....")
youtube = pytube.YouTube(url)
video = youtube.streams.first()
video.download(r'C:\Users\Silver\Downloads\video.3gpp')
print("Converting video....")
clip = mp.VideoFileClip(r"C:\Users\Silver\Downloads\video.3gpp")
clip.audio.write_audiofile(r"C:\Users\Silver\Desktop\INFO\PythonFiles\Python\Youtube MP3 Converter\mp3 conv")
错误:
Traceback (most recent call last):
File "C:\Users\Silver\AppData\Local\Programs\Python\Python39\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 285, in ffmpeg_parse_infos
line = [l for l in lines if keyword in l][index]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Silver\Desktop\INFO\PythonFiles\Python\Youtube MP3 Converter\Mp3Conv.py", line 12, in <module>
clip = mp.VideoFileClip(r"C:\Users\Silver\Downloads\video.3gpp")
File "C:\Users\Silver\AppData\Local\Programs\Python\Python39\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 88, in __init__
self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
File "C:\Users\Silver\AppData\Local\Programs\Python\Python39\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 35, in __init__
infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
File "C:\Users\Silver\AppData\Local\Programs\Python\Python39\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 289, in ffmpeg_parse_infos
raise IOError(("MoviePy error: failed to read the duration of file %s.\n"
OSError: MoviePy error: failed to read the duration of file C:\Users\Silver\Downloads\video.3gpp.
Here are the file infos returned by ffmpeg:
ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt
libavutil 56. 31.100 / 56. 31.100
libavcodec 58. 54.100 / 58. 54.100
libavformat 58. 29.100 / 58. 29.100
libavdevice 58. 8.100 / 58. 8.100
libavfilter 7. 57.100 / 7. 57.100
libswscale 5. 5.100 / 5. 5.100
libswresample 3. 5.100 / 3. 5.100
libpostproc 55. 5.100 / 55. 5.100
C:\Users\Silver\Downloads\video.3gpp: Permission denied
解决方案
推荐阅读
- python - 如果一个四位回文数abba/bb等于一个整数,那么有多少个abba?
- c# - 我想使用 jQuery DataTable 但我收到错误
- ios - VNDocumentCameraViewController 文档检测框的自定义颜色(自动快门)
- java - 如何在函数中返回通用对象?
- c++ - 如何使用 cmake 变量提供自定义库位置(使用 cmake 编译 SYSTRAN/fuzzy-match 项目)?
- node.js - 如何在连接到对话流的 Facebook Bot 上添加持久菜单
- javascript - 无法将 JavaScript 元素附加到 Div
- routes - 本地域都路由到同一个应用程序 - Laravel Homestead
- etl - 实现触发器如果文件共享中删除了任何文件(Windows),则触发我的 ADF 管道。管道 3 和 2 在管道 1 完成后运行
- flutter - Flutter & Firebase:当帐户来自社交认证时,电子邮件和密码重置如何工作?