pip install ffmpeg
pip install moviepy
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
(wind_2021) L:\> (wind_2021) L:\> (wind_2021) L:\>pip install ffmpeg Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting ffmpeg Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f0/cc/3b7408b8ecf7c1d20ad480c3eaed7619857bf1054b690226e906fdf14258/ffmpeg-1.4.tar.gz (5.1 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: ffmpeg Building wheel for ffmpeg (setup.py) ... done Created wheel for ffmpeg: filename=ffmpeg-1.4-py3-none-any.whl size=6083 sha256=593b32b67243b003503c4c51af80cdead7bccc83fc75b020ea94bfe4200f0927 Stored in directory: c:\users\luo\appdata\local\pip\cache\wheels\81\12\64\7484404a25365c98fbeb12c05477bb30dbc06a8682d0d8f2d6 Successfully built ffmpeg Installing collected packages: ffmpeg Successfully installed ffmpeg-1.4 (wind_2021) L:\> (wind_2021) L:\> (wind_2021) L:\> (wind_2021) L:\>pip install moviepy Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting moviepy Downloading https://pypi.tuna.tsinghua.edu.cn/packages/18/54/01a8c4e35c75ca9724d19a7e4de9dc23f0ceb8769102c7de056113af61c3/moviepy-1.0.3.tar.gz (388 kB) ---------------------------------------- 388.3/388.3 kB 4.8 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Collecting decorator<5.0,>=4.0.2 (from moviepy) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ed/1b/72a1821152d07cf1d8b6fce298aeb06a7eb90f4d6d41acec9861e7cc6df0/decorator-4.4.2-py2.py3-none-any.whl (9.2 kB) Requirement already satisfied: tqdm<5.0,>=4.11.2 in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from moviepy) (4.64.0) Requirement already satisfied: requests<3.0,>=2.8.1 in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from moviepy) (2.26.0) Collecting proglog<=1.0.0 (from moviepy) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8b/f5/cab5cf6a540c31f5099043de0ae43990fd9cf66f75ecb5e9f254a4e4d4ee/proglog-0.1.10-py3-none-any.whl (6.1 kB) Requirement already satisfied: numpy>=1.17.3 in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from moviepy) (1.21.3) Collecting imageio<3.0,>=2.5 (from moviepy) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e9/67/98ed2279fcd66cc50112abb8f5a3de4526307dc43a16d220d7b48afd113a/imageio-2.28.1-py3-none-any.whl (3.4 MB) ---------------------------------------- 3.4/3.4 MB 5.7 MB/s eta 0:00:00 Collecting imageio_ffmpeg>=0.2.0 (from moviepy) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7f/1d/9d9bb0beef06704cb3acb7cab8673b451d4528ee6cc9b231d1284aa1ed75/imageio_ffmpeg-0.4.8-py3-none-win_amd64.whl (22.6 MB) ---------------------------------------- 22.6/22.6 MB 5.8 MB/s eta 0:00:00 Requirement already satisfied: pillow>=8.3.2 in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from imageio<3.0,>=2.5->moviepy) (8.4.0) Requirement already satisfied: urllib3<1.27,>=1.21.1 in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from requests<3.0,>=2.8.1->moviepy) (1.26.7) Requirement already satisfied: certifi>=2017.4.17 in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from requests<3.0,>=2.8.1->moviepy) (2021.10.8) Requirement already satisfied: charset-normalizer~=2.0.0 in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from requests<3.0,>=2.8.1->moviepy) (2.0.7) Requirement already satisfied: idna<4,>=2.5 in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from requests<3.0,>=2.8.1->moviepy) (3.3) Requirement already satisfied: colorama in l:\anaconda_2021\install\envs\wind_2021\lib\site-packages (from tqdm<5.0,>=4.11.2->moviepy) (0.4.4) 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=110744 sha256=014b5cdb2e0d2289de98aaa0f2e50da061251c7496d24c388946ca56a73bdd48 Stored in directory: c:\users\luo\appdata\local\pip\cache\wheels\19\c5\56\7bd7ec94257958e82bbcf8d4eb85a5acfae1b5eb3f4f64128a Successfully built moviepy Installing collected packages: imageio_ffmpeg, imageio, decorator, proglog, moviepy Attempting uninstall: decorator Found existing installation: decorator 5.1.1 Uninstalling decorator-5.1.1: Successfully uninstalled decorator-5.1.1 Successfully installed decorator-4.4.2 imageio-2.28.1 imageio_ffmpeg-0.4.8 moviepy-1.0.3 proglog-0.1.10 (wind_2021) L:\>View Code
import moviepy.editor as mp def extract_audio(videos_file_path): my_clip = mp.VideoFileClip(videos_file_path) return my_clip file_path = r"202305221404.mp4" my_clip = extract_audio(file_path) my_clip.audio.write_audiofile(f'202305221404.mp3')
参考:https://blog.csdn.net/ZXYbbb/article/details/125669205
###################
标签:moviepy,ffmpeg,python,音频,导出,2021,install,packages,wind From: https://www.cnblogs.com/herd/p/17420582.html