refine quality test
This commit is contained in:
94
bin/ffx.py
94
bin/ffx.py
@@ -38,14 +38,16 @@ def generateVP9Pass2Tokens(q):
|
||||
'-frame-parallel', '0', '-g', '9999', '-aq-mode', '0',
|
||||
'-auto-alt-ref', '1', '-lag-in-frames', '25']
|
||||
|
||||
def generateCropTokens(start, length):
|
||||
|
||||
def generateOutputTokens(f):
|
||||
return ['-f', 'webm', f]
|
||||
return ['-ss', str(start), '-t', str(length)]
|
||||
|
||||
def generateTestOutputTokens(f, q):
|
||||
def generateOutputTokens(f, q=''):
|
||||
if q:
|
||||
fTokens = f.split('.')
|
||||
return ['-f', 'webm', fTokens[:-1] + [f" q{q}"] + fTokens[-1]]
|
||||
|
||||
else:
|
||||
return ['-f', 'webm', f]
|
||||
|
||||
|
||||
inputFilename = sys.argv[1]
|
||||
@@ -58,18 +60,12 @@ if 'vp9' in sys.argv:
|
||||
targetFormat = 'vp9'
|
||||
|
||||
|
||||
testQualities = []
|
||||
testTokens = [q for q in sys.argv if q.startswith('test=')]
|
||||
if testTokens:
|
||||
qualitiesString = testTokens[0].split('=')[1]
|
||||
qualities = [DEFAULT_QUALITY]
|
||||
qualitiesTokens = [q for q in sys.argv if q.startswith('q=')]
|
||||
if qualitiesTokens:
|
||||
qualitiesString = qualitiesTokens[0].split('=')[1]
|
||||
testQualities = qualitiesString.split(',')
|
||||
|
||||
|
||||
quality = DEFAULT_QUALITY
|
||||
qualityTokens = [q for q in sys.argv if q.startswith('q=')]
|
||||
if qualityTokens:
|
||||
quality = int(qualityTokens[0].split('=')[1])
|
||||
|
||||
preset = DEFAULT_AV1_PRESET
|
||||
presetTokens = [p for p in sys.argv if p.startswith('p=')]
|
||||
if presetTokens:
|
||||
@@ -96,6 +92,13 @@ if dtsTokens:
|
||||
if not dtsBandwidth.endswith('k'):
|
||||
dtsBandwidth += "k"
|
||||
|
||||
cropStart = -1
|
||||
cropLength = -1
|
||||
cropTokens = [c for c in sys.argv if c.startswith('crop=')]
|
||||
if cropTokens:
|
||||
cropString = cropTokens[0].split('=')[1]
|
||||
cropStart, cropLength = cropString.split(',')
|
||||
|
||||
|
||||
output = executeProcess(["ffprobe", "-show_streams", "-of", "json" ,inputFilename])
|
||||
|
||||
@@ -150,65 +153,56 @@ for aStream in audioStreams:
|
||||
audioStreamIndex += 1
|
||||
|
||||
|
||||
|
||||
outputTokens = ['-f', 'webm', outputFilename]
|
||||
|
||||
nullTokens = ['-f', 'null', '/dev/null']
|
||||
|
||||
|
||||
testTokens = ['-ss', '60', '-t', '180']
|
||||
|
||||
|
||||
|
||||
|
||||
if testQualities:
|
||||
|
||||
for testQ in testQualities:
|
||||
for quality in qualities:
|
||||
|
||||
if targetFormat == 'av1':
|
||||
|
||||
commandSequence = commandTokens + mappingTokens + generateAV1Tokens(testQ, preset) + audioTokens + testTokens + generateTestOutputTokens(outputFilename, testQ)
|
||||
|
||||
print(f"Command Sequence: {commandSequence}")
|
||||
|
||||
executeProcess(commandSequence)
|
||||
|
||||
|
||||
if targetFormat == 'vp9':
|
||||
|
||||
commandSequence1 = commandTokens + generateVP9Pass1Tokens(testQ) + testTokens + nullTokens
|
||||
|
||||
print(f"Command Sequence 1: {commandSequence1}")
|
||||
|
||||
executeProcess(commandSequence1)
|
||||
|
||||
commandSequence2 = commandTokens + mappingTokens + generateVP9Pass2Tokens(testQ) + audioTokens + testTokens + generateTestOutputTokens(outputFilename, testQ)
|
||||
|
||||
print(f"Command Sequence 2: {commandSequence2}")
|
||||
|
||||
executeProcess(commandSequence2)
|
||||
|
||||
commandSequence = commandTokens + mappingTokens + generateAV1Tokens(quality, preset) + audioTokens
|
||||
|
||||
if len(qualities) > 1:
|
||||
commandSequence += generateOutputTokens(outputFilename, quality)
|
||||
else:
|
||||
commandSequence += generateOutputTokens(outputFilename)
|
||||
|
||||
if targetFormat == 'av1':
|
||||
if cropStart > -1:
|
||||
commandSequence += generateCropTokens(cropStart, cropLength)
|
||||
|
||||
commandSequence = commandTokens + mappingTokens + generateAV1Tokens(quality, preset) + audioTokens + generateOutputTokens(outputFilename)
|
||||
|
||||
print(f"Command Sequence: {commandSequence}")
|
||||
|
||||
executeProcess(commandSequence)
|
||||
|
||||
|
||||
if targetFormat == 'vp9':
|
||||
|
||||
commandSequence1 = commandTokens + generateVP9Pass1Tokens(quality) + audioTokens + nullTokens
|
||||
commandSequence1 = commandTokens + generateVP9Pass1Tokens(quality) + nullTokens
|
||||
|
||||
|
||||
if cropStart > -1:
|
||||
commandSequence += generateCropTokens(cropStart, cropLength)
|
||||
|
||||
|
||||
print(f"Command Sequence 1: {commandSequence1}")
|
||||
|
||||
executeProcess(commandSequence1)
|
||||
|
||||
commandSequence2 = commandTokens + mappingTokens + generateVP9Pass2Tokens(quality) + audioTokens + generateOutputTokens(outputFilename)
|
||||
commandSequence2 = commandTokens + mappingTokens + generateVP9Pass2Tokens(quality) + audioTokens
|
||||
|
||||
|
||||
if cropStart > -1:
|
||||
commandSequence += generateCropTokens(cropStart, cropLength)
|
||||
|
||||
|
||||
if len(qualities) > 1:
|
||||
commandSequence2 += generateOutputTokens(outputFilename, quality)
|
||||
else:
|
||||
commandSequence2 += generateOutputTokens(outputFilename)
|
||||
|
||||
|
||||
print(f"Command Sequence 2: {commandSequence2}")
|
||||
|
||||
executeProcess(commandSequence2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user