Convert MP4 files to MP3

Code

#mp4_to_mp3.py
import glob
import moviepy.editor as mp

res_paths = glob.glob ('*mp4')

print(res_paths)

def extract_audio(videos_file_path):
    my_clip = mp.VideoFileClip(videos_file_path)
    new_name = videos_file_path.split('.mp4')[0]
    my_clip.audio.write_audiofile(f'{new_name}.mp3')

for i in res_paths:
    extract_audio(i)

Usage

Requirement: python

  1. Install python package glob and moviepy
  2. Put the python file in the mp4 folder.
    ---folder: my_video_folder---
    - mp4_to_mp3.py
    - Video.mp4
  3. Open the folder in Terminal (e.g. cd D:/my_video_folder)
  4. Run python mp4_to_mp3.py
Author: Xuan
Copyright: CC BY-NC-SA 4.0
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next