当前位置:网站首页>How to extract MP3 audio from MP4 video files?
How to extract MP3 audio from MP4 video files?
2022-07-06 00:54:00 【Zhuoqing】
Jane Medium : In order to be able to process audio in video , Two methods of extracting audio from video are tested . One is to use format engineering software, the other is to use ffmpeg Software .
key word
: Video file , Audio file ,mp4,mp3
§01 carry Take audio
1.1 Video source
Today, in wechat, my friend sent me an interesting video . This video demonstrates that the fresh and elegant plucking music comes from the nine rubber bands on the lunch box , People can't help feeling Flying flowers and picking leaves can hurt people , Grass, wood, bamboo and stone are all swords , I will not deceive you .
▲ chart 1 Lunch box 、 chopsticks 、 elastic
Now leave a question :
- What is the frequency of each note in this piece of music ?
- Under certain assumptions , Whether the vibration frequency corresponding to each rubber band meets the requirements of musical syllables ?
1.2 Audio extraction
To answer the above questions , The first step is to start from MP4
Extract the video and audio from the file . have access to Format Factory (Format Factory) Complete the extraction of audio data .
1.2.1 Use format factory to extract audio
(1) Download format engineering software
from Format Factory (Format Factory) Download and install the latest version of software .
▲ chart 1.2.1 install Format Factory Software
(2) Separate the audio in the video file
Use the “ ->MP3” take MP4
Separate the audio in the file .
▲ chart 1.2.2 utilize Format Factory Separate MP3
(3) Audio preprocessing
utilize Audacity Software is separate MP3
Audio file preprocessing .
Use the Special effects in growth Amplify the original audio waveform . The following is the amplified audio waveform .
▲ chart 1.2.3 utilize Audacity Preprocess audio files
1.2.2 utilize moviepy Extract audio
stay bing In the use of “python extract MP4 sounds” Search for , You can get the following blog post :
Applications are given in the blog moviepy
To extract audio data from video .
(1) Processing software
from headm import * # =
from moviepy.editor import *
def mp4tomp3(mp4file, mp3file):
videoclip = VideoFileClip(mp4file)
audioclip = videoclip.audio
audioclip.write_audiofile(mp4file)
audioclip.close()
videoclip.close()
mp4filename = r'D:\Temp\WeChat_20220213170345.mp4'
mp3filename = mp4filename.split('.')[0] + '.mp3'
printt(mp4filename|, mp3filename:)
mp4tomp3(mp4filename, mp3filename)
(2) Running error
An error occurred after running :
---------- [PYTHON INFOR] ----------
MoviePy - Writing audio in D:\Temp\WeChat_20220213170345.mp4
chunk: 0%| | 0/507 [00:00<?, ?it/s, now=None]
chunk: 0%| | 0/507 [00:00<?, ?it/s, now=None]chunk: 4%|▉ | 21/507 [00:00<00:02, 209.99it/s, now=None]Traceback (most recent call last):
File "C:\Users\zhuoqing\Anaconda3\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 74, in write_frames
self.proc.stdin.write(frames_array.tobytes())
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Temp\TEMP0001\test1.PY", line 25, in <module>
mp4tomp3(mp4filename, mp3filename)
File "D:\Temp\TEMP0001\test1.PY", line 15, in mp4tomp3
audioclip.write_audiofile(mp4file)
File "<C:\Users\zhuoqing\Anaconda3\lib\site-packages\decorator.py:decorator-gen-45>", line 2, in write_audiofile
File "C:\Users\zhuoqing\Anaconda3\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\zhuoqing\Anaconda3\lib\site-packages\moviepy\audio\AudioClip.py", line 210, in write_audiofile
logger=logger)
File "<C:\Users\zhuoqing\Anaconda3\lib\site-packages\decorator.py:decorator-gen-9>", line 2, in ffmpeg_audiowrite
File "C:\Users\zhuoqing\Anaconda3\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
return f(clip, *a, **k)
File "C:\Users\zhuoqing\Anaconda3\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 170, in ffmpeg_audiowrite
writer.write_frames(chunk)
File "C:\Users\zhuoqing\Anaconda3\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 117, in write_frames
raise IOError(error)
OSError: [Errno 32] Broken pipe
MoviePy error: FFMPEG encountered the following error while writing file D:\Temp\WeChat_20220213170345.mp4:
b"Invalid encoder type 'libx264'\r\n"
In case it helps, make sure you are using a recent version of FFMPEG (the versions in the Ubuntu/Debian repos are deprecated).
Exception ignored in: <function FFMPEG_AudioWriter.__del__ at 0x0000000017880268>
Traceback (most recent call last):
File "C:\Users\zhuoqing\Anaconda3\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 132, in __del__
self.close()
File "C:\Users\zhuoqing\Anaconda3\lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py", line 121, in close
self.proc.stdin.close()
OSError: [Errno 22] Invalid argument
This shows a problem , It needs to be installed correctly in the software FFMPEG Software .
The question is Python extract wav from video file Also mentioned by netizens , How to avoid using ffmpeg.
My question is how could I extract wav audio track from video file, say video.avi? I read many articles and everywhere people suggest to use (from Python) ffmpeg as a subprocess (because there are no reliable python bindings to ffmpeg - the only hope was PyFFmpeg but i found it is unmaintaned now). I don’t know if it is right solution and i am looking for good one.
I looked to gstreamer and found it nice but unable to satisfy my needs – the only way I found to accomplish this from command line looks like、
This situation has been found by netizens in the process of use that it must be installed FFMPEGA, such as For a while mp4 Extract and save the audio in the original directory python Script .
▲ chart 1.2.4 You can't get around it ffmpeg Software
Even in Extract MP3 audio from Videos using a Python script take ffmpeg Repackaged as a function called to get MP4 Audio data in .
1.2.3 install ffmpeg
Since I can't get around , Then install ffmpeg Software . stay How to Install FFmpeg on Windows The installation is given ffmpeg Methods .
(1) download ffmpeg
stay ffmpeg Official website : https://ffmpeg.org/download.html Download the required software version .
▲ chart 1.2.5 FFMPEG Official download software
Here are two Windows EXE files Download link :
- Windows builds from gyan.dev
- Windows builds by btbN
I don't know the difference between the two versions , Now choose the first :builds from gyan.dev.
▲ chart 1.2.6 choice Windows EXE edition
▲ chart 1.2.7 Choose to download the distribution
After downloading is a ZIP Compressed files :
- D:\Temp\ffmpeg-5.0-essentials_build.zip
(2) Unzip the file
utilize Windows Version of Bandizip Compress it .
Decompression produces ffmpeg Catalog , It includes bin Catalog , It includes ffmpeg.exe Executable file .
└─ffmpeg-5.0-essentials_build
│ LICENSE
│ README.txt
├─bin
│ ffmpeg.exe
│ ffplay.exe
│ ffprobe.exe
├─doc
│ bootstrap.min.css
│ default.css
│ developer.html
│ faq.html
│ fate.html
│ ffmpeg-all.html
│ ffmpeg-bitstream-filters.html
│ ffmpeg-codecs.html
│ ffmpeg-devices.html
│ ffmpeg-filters.html
│ ffmpeg-formats.html
│ ffmpeg-protocols.html
│ ffmpeg-resampler.html
│ ffmpeg-scaler.html
│ ffmpeg-utils.html
│ ffmpeg.html
│ ffplay-all.html
│ ffplay.html
│ ffprobe-all.html
│ ffprobe.html
│ general.html
│ git-howto.html
│ libavcodec.html
│ libavdevice.html
│ libavfilter.html
│ libavformat.html
│ libavutil.html
│ libswresample.html
│ libswscale.html
│ mailing-list-faq.html
│ nut.html
│ platform.html
│ style.min.css
└─presets
libvpx-1080p.ffpreset
libvpx-1080p50_60.ffpreset
libvpx-360p.ffpreset
libvpx-720p.ffpreset
libvpx-720p50_60.ffpreset
(3) Add environment variables
take ffmpeg
Of bin
Add in System settings Medium path variable . adopt edit Can be bin The catalog is pasted on path Last . Use a semicolon in the middle “;” separate .
▲ chart 1.2.8 Set environment variables of the system
(4) test FFMPEG
Use the following command to extract the audio in the video :
ffmpeg -i music.mp4 music.wav
ffmpeg -i music.mp4 music.mp3
The above two commands can be generated separately music.wav, music.mp3 file .
※ carry Take a summary ※
by It can process audio in video , Two methods of extracting audio from video are tested . One is to use format engineering software, the other is to use ffmpeg Software .
■ Links to related literature :
- Format Factory (Format Factory)
- How to Extract Audio from Video files (Mp3 From Mp4)
- Python extract wav from video file
- For a while mp4 Extract and save the audio in the original directory python Script
- Extract MP3 audio from Videos using a Python script
- How to Install FFmpeg on Windows
- ffmpeg Official website
- Windows Version of Bandizip
● Related chart Links :
- chart 1 Lunch box 、 chopsticks 、 elastic
- chart 1.2.1 install Format Factory Software
- chart 1.2.2 utilize Format Factory Separate MP3
- chart 1.2.3 utilize Audacity Preprocess audio files
- chart 1.2.4 You can't get around it ffmpeg Software
- chart 1.2.5 FFMPEG Official download software
- chart 1.2.6 choice Windows EXE edition
- chart 1.2.7 Choose to download the distribution
- chart 1.2.8 Set environment variables of the system
边栏推荐
- Ffmpeg captures RTSP images for image analysis
- 2020.2.13
- Promise
- The relationship between FPGA internal hardware structure and code
- Spark SQL空值Null,NaN判断和处理
- ADS-NPU芯片架构设计的五大挑战
- Cf:d. insert a progression [about the insert in the array + the nature of absolute value + greedy top-down]
- Five challenges of ads-npu chip architecture design
- MYSQL GROUP_ The concat function realizes the content merging of the same ID
- Anconda download + add Tsinghua +tensorflow installation +no module named 'tensorflow' +kernelrestart: restart failed, kernel restart failed
猜你喜欢
Arduino hexapod robot
Finding the nearest common ancestor of binary tree by recursion
Four dimensional matrix, flip (including mirror image), rotation, world coordinates and local coordinates
The population logic of the request to read product data on the sap Spartacus home page
Spark AQE
免费的聊天机器人API
I'm interested in watching Tiktok live beyond concert
The third season of ape table school is about to launch, opening a new vision for developers under the wave of going to sea
SAP Spartacus home 页面读取 product 数据的请求的 population 逻辑
Analysis of the combination of small program technology advantages and industrial Internet
随机推荐
Four commonly used techniques for anti aliasing
云导DNS和知识科普以及课堂笔记
朝招金安全吗 会不会亏损本金
Meta AI西雅图研究负责人Luke Zettlemoyer | 万亿参数后,大模型会持续增长吗?
Spark AQE
curlpost-php
几百行代码实现一个 JSON 解析器
Spark-SQL UDF函数
STM32按键消抖——入门状态机思维
Ffmpeg captures RTSP images for image analysis
CTF daily question day44 rot
Promise
Arduino hexapod robot
图解网络:TCP三次握手背后的原理,为啥两次握手不可以?
KDD 2022 | 脑电AI助力癫痫疾病诊断
面试必刷算法TOP101之回溯篇 TOP34
SAP Spartacus home 页面读取 product 数据的请求的 population 逻辑
[groovy] JSON serialization (jsonbuilder builder | generates JSON string with root node name | generates JSON string without root node name)
Study diary: February 13, 2022
Beginner redis