# -*- coding: cp936 -*-
import os
import sys
import re
pattern = re.compile(r'[0-9]{2,4}')# find the successive 2~4 num.
DataSet_264='C:/Users/Dell/Desktop/264DataSet/' #destination folder for saving output .264 files.
YUV_VIDEO_FOLDER='C:/Users/Dell/Desktop/YUVDataSet/' #source folder containing YUV videos
for YUV_video in os.listdir(YUV_VIDEO_FOLDER): #yuv video的名字里面包含了高度,宽度,视频长度等信息。所以只需要在名字中提取。
#print YUV_video
video_inf=pattern.findall(YUV_video)
video_width=int(video_inf[0])
video_height=int(video_inf[1])
video_frame=int(video_inf[2])
inputfile=YUV_VIDEO_FOLDER+YUV_video
outputfile=DataSet_264+YUV_video+'.264'
fin=open('C:/Users/Dell/Desktop/jm_16.1_xmltrace_v1.5/jm_16.1/bin/encoder_baseline.cfg',"rb")
fout= open('C:/Users/Dell/Desktop/jm_16.1_xmltrace_v1.5/jm_16.1/bin/encoder_baseline_new.cfg', "w")
for index, line in enumerate(fin): #枚举出所打开文件的行数和改行的内容。
if index==12:
line=" InputFile = %s " % inputfile
if index==15:
line="FramesToBeEncoded = %d " % video_frame
if index==17:
line=" SourceWidth = %d " % video_width
if index==18:
line="SourceHeight = %d " % video_height
if index==20:
line="OutputWidth = %d " % video_width
if index==21:
line="OutputHeight = %d " % video_height
if index==25:
line="OutputFile = %s " % outputfile
fout.write(line+'\n')# 将修改写入新文件。
fin.close()
fout.close()
os.system('C:/Users/Dell/Desktop/jm_16.1_xmltrace_v1.5/jm_16.1/bin/lencod.exe -d C:/Users/Dell/Desktop/jm_16.1_xmltrace_v1.5/jm_16.1/bin/encoder_baseline_new.cfg') #利用CMD运行lencod.exe 执行编码。
264 编码,写了个脚本,实现批量编码
最新推荐文章于 2023-11-01 14:57:00 发布