Table of Contents
pip install MoviePy
import os
import moviepy.editor as moviepy
# clip = moviepy.VideoFileClip("wmv/BAI001.wmv")
# clip.write_videofile("mp4/BAI001.mp4")
import glob
# for filepath in glob.iglob('wmv/*.wmv'):
# print(filepath)
# https://stackoverflow.com/questions/57344112/how-to-convert-video-on-python-to-mp4-without-ffmpeg/57344149
directory = '/work/DEV/longdt/Documents/video vtv3/wmv/'
f = []
for (dirpath, dirnames, filenames) in os.walk(directory):
f.extend(filenames)
break
# print(len(f))
# print(f)
# print(f[0])
# print(os.path.splitext(f[0])[0])
for i in f:
print(i)
indir = '/work/DEV/longdt/Documents/video vtv3/wmv'
outdir = '/work/DEV/longdt/Documents/video vtv3/mp4'
src = '%s/%s' % (indir,i)
dst = '%s/%s.mp4' % (outdir,os.path.splitext(i)[0])
try:
print(src)
print(dst)
clip = moviepy.VideoFileClip(src)
clip.write_videofile(dst)
except:
print("Lỗi")
# break