以调整分辨率为例:
import os
import subprocess
def resize_mp4(path):
'''ffmpeg -i test.mp4 -s 1280x720 test_r.mp4'''
for i in os.listdir(path):
if i.endswith('.mp4'):
print(i)
video_name = i.split('.')[0]
cmd_1 = 'ffmpeg -i {}/{}.mp4 -s 1280x720 {}/{}_r.mp4'.format(path, video_name, path, video_name)
p1 = subprocess.Popen(cmd_1, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
out, err = p1.communicate()