前提:安装 ffmpeg
方式1: 通过控制台调用
ffmpeg -f h264 -i test10.h264 -vcodec copy test.mp4
方式2: 通过python 代码调用
import os
‘’‘
sourcePath h264的文件路径,例如 ./test.h264
tagPath 要生成的mp4文件路径
’‘’
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)