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