1
2import os
3import glob
4from pydub import AudioSegment
5
6video_dir = 'D:/Movies/Urdu Songs/New folder' # Path where the videos are located
7extension_list = ('*.mp4', '*.flv')
8
9os.chdir(video_dir)
10for extension in extension_list:
11 for video in glob.glob(extension):
12 mp3_filename = os.path.splitext(os.path.basename(video))[0] + '.mp3'
13 AudioSegment.from_file(video).export(mp3_filename, format='mp3')
14
15