展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

视频转音频

  • 一些在下转换网站有时间限制,使用python转换

  • 安装anaconda,安装依赖

C:\Users\dogle>activate env_dev1

(env_dev1) C:\Users\dogle>pip install moviepy
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
Collecting moviepy
  Downloading moviepy-2.1.1-py3-none-any.whl (123 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.5/123.5 kB 557.9 kB/s eta 0:00:00
Collecting imageio<3.0,>=2.5
  Downloading imageio-2.31.2-py3-none-any.whl (313 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 313.2/313.2 kB 2.1 MB/s eta 0:00:00
Collecting moviepy
  Downloading moviepy-2.1.0-py3-none-any.whl (123 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.4/123.4 kB 3.7 MB/s eta 0:00:00
  Downloading moviepy-2.0.0-py3-none-any.whl (122 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 123.0/123.0 kB 3.5 MB/s eta 0:00:00
  Downloading moviepy-1.0.3.tar.gz (388 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 388.3/388.3 kB 3.5 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting decorator<5.0,>=4.0.2
  Downloading decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Collecting tqdm<5.0,>=4.11.2
  Downloading tqdm-4.67.1-py3-none-any.whl (78 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 78.5/78.5 kB 4.3 MB/s eta 0:00:00
Requirement already satisfied: requests<3.0,>=2.8.1 in d:\.conda\envs\env_dev1\lib\site-packages (from moviepy) (2.31.0)
Collecting proglog<=1.0.0
  Downloading proglog-0.1.10-py3-none-any.whl (6.1 kB)
Requirement already satisfied: numpy>=1.17.3 in d:\.conda\envs\env_dev1\lib\site-packages (from moviepy) (1.18.5)
Collecting imageio_ffmpeg>=0.2.0
  Downloading imageio_ffmpeg-0.5.1-py3-none-win_amd64.whl (22.6 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 22.6/22.6 MB 4.0 MB/s eta 0:00:00
Requirement already satisfied: pillow>=8.3.2 in d:\.conda\envs\env_dev1\lib\site-packages (from imageio<3.0,>=2.5->moviepy) (9.5.0)
Requirement already satisfied: setuptools in d:\.conda\envs\env_dev1\lib\site-packages (from imageio_ffmpeg>=0.2.0->moviepy) (65.6.3)
Requirement already satisfied: idna<4,>=2.5 in d:\.conda\envs\env_dev1\lib\site-packages (from requests<3.0,>=2.8.1->moviepy) (3.7)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\.conda\envs\env_dev1\lib\site-packages (from requests<3.0,>=2.8.1->moviepy) (3.3.2)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\.conda\envs\env_dev1\lib\site-packages (from requests<3.0,>=2.8.1->moviepy) (2.0.7)
Requirement already satisfied: certifi>=2017.4.17 in d:\.conda\envs\env_dev1\lib\site-packages (from requests<3.0,>=2.8.1->moviepy) (2022.12.7)
Collecting colorama
  Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)
Building wheels for collected packages: moviepy
  Building wheel for moviepy (setup.py) ... done
  Created wheel for moviepy: filename=moviepy-1.0.3-py3-none-any.whl size=110773 sha256=5b983ab64461e5ba899ae9cfafb1382788ba08f0b0a602eed37964d504cefd7f
  Stored in directory: c:\users\dogle\appdata\local\pip\cache\wheels\d7\37\b3\344c443bba4ba867458f703838f77df49bfa00c855d5511548
Successfully built moviepy
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
Installing collected packages: imageio_ffmpeg, imageio, decorator, colorama, tqdm, proglog, moviepy
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
Successfully installed colorama-0.4.6 decorator-4.4.2 imageio-2.31.2 imageio_ffmpeg-0.5.1 moviepy-1.0.3 proglog-0.1.10 tqdm-4.67.1
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
WARNING: Ignoring invalid distribution -umpy (d:\.conda\envs\env_dev1\lib\site-packages)
  • 将视频文件放在D盘,编写代码转换
from moviepy.editor import VideoFileClip

# 输入视频文件路径
video_file_path = 'D:\qqq.mp4'

# 输出音频文件路径
audio_file_path = 'D:\qqq.mp3'

# 加载视频文件
video = VideoFileClip(video_file_path)

# 提取音频并写入文件
video.audio.write_audiofile(audio_file_path)

print(f"音频文件已保存到 {audio_file_path}")
  • cmd中执行py文件进行转换
(env_dev1) C:\Users\dogle>python C:\Users\dogle\Desktop\aa.py
MoviePy - Writing audio in D:\qqq.mp3
MoviePy - Done.
音频文件已保存到 D:\qqq.mp3
posted @ 2024-11-27 15:08  DogLeftover  阅读(9)  评论(0编辑  收藏  举报