python完整项目递归文件夹 放大视频音量

 first  先安装需要的版本

pip install moviepy==1.0.0

然后代码如下

import os
from moviepy.editor import VideoFileClip, concatenate_videoclips


def batch_volumex(path):
    # 函数功能:在指定路径下,将该文件夹的视频声音调为x倍
    origin_path = os.getcwd()
    os.chdir(path)
    for fname in os.listdir():
        genNewFile(fname)
    os.chdir(origin_path)


def genNewFile(fname):
    clip = VideoFileClip(fname)
    #放大三倍音量
    newclip = clip.volumex(5)
    newclip.write_videofile("new_" + fname)


def eachFile(filepath):
    global datas
    fileNames = os.listdir(filepath)  # 获取当前路径下的文件名,返回List
    for file in fileNames:
        newDir = filepath + '/' + file # 将文件命加入到当前文件路径后面
        # print(newDir)
        # if os.path.isdir(newDir): # 如果是文件夹
        if os.path.isfile(newDir):  # 如果是文件

            if os.path.splitext(newDir)[1] == ".mp4" and not file.__contains__("new_"):  # 判断是否是txt
                print(newDir)
                os.chdir(filepath)
                genNewFile(file)
                os.chdir(filepath)
        else:
            eachFile(newDir)                #如果不是文件,递归这个文件夹的路径
datas = []
def main():
    # 文件夹目录
    path = r'C:\Users\liuan\Desktop\android开发从入门到项目'


    eachFile(path)
    print(datas)
    pass


if __name__ == '__main__':
    main()

最后贴个小广告

这个是我本人录制的教学视频。正在准备提升音量

https://edu.csdn.net/course/detail/27011

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安果移不动

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值