python将h264文件视频转为mp4格式

import os


def h264ToMp4(sourcePath, tagPath):
    cmd = 'ffmpeg -f h264 -i ' + sourcePath + ' -vcodec copy ' + tagPath
    print(">>cmd:\n %s" % (cmd))
    result = os.popen(cmd).read().strip()
    print(">>result :", result)

for i in os.listdir("1"):
    re=i.split(".")[0]+".mp4"
    source=os.path.join("1",i)
    h264ToMp4(source,re)

 

posted @ 2022-03-25 17:46  Tomorrow1126  阅读(794)  评论(0编辑  收藏  举报