|
|
|
@ -17,6 +17,37 @@ def executeProcess(commandSequence):
|
|
|
|
|
return output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generateAV1Tokens(q, p):
|
|
|
|
|
|
|
|
|
|
return ['-c:v:0',
|
|
|
|
|
'libsvtav1',
|
|
|
|
|
'-svtav1-params',
|
|
|
|
|
f"crf={q}:preset={p}:tune=0:enable-overlays=1:scd=1:scm=0",
|
|
|
|
|
'-pix_fmt', 'yuv420p10le']
|
|
|
|
|
|
|
|
|
|
def generateVP9Pass1Tokens(q):
|
|
|
|
|
|
|
|
|
|
return ['-c:v:0', 'libvpx-vp9', '-row-mt', '1',
|
|
|
|
|
'-crf', str(q), '-pass', '1', '-speed', '4',
|
|
|
|
|
'-frame-parallel', '0', '-g', '9999', '-aq-mode', '0']
|
|
|
|
|
|
|
|
|
|
def generateVP9Pass2Tokens(q):
|
|
|
|
|
|
|
|
|
|
return ['-c:v:0', 'libvpx-vp9', '-row-mt', '1',
|
|
|
|
|
'-crf', str(q), '-pass', '2',
|
|
|
|
|
'-frame-parallel', '0', '-g', '9999', '-aq-mode', '0',
|
|
|
|
|
'-auto-alt-ref', '1', '-lag-in-frames', '25']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generateOutputTokens(f):
|
|
|
|
|
return ['-f', 'webm', f]
|
|
|
|
|
|
|
|
|
|
def generateTestOutputTokens(f, q):
|
|
|
|
|
fTokens = f.split('.')
|
|
|
|
|
return ['-f', 'webm', fTokens[:-1] + [f" q{q}"] + fTokens[-1]]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputFilename = sys.argv[1]
|
|
|
|
|
outputFilename = sys.argv[2]
|
|
|
|
|
|
|
|
|
@ -26,6 +57,14 @@ if 'av1' in sys.argv:
|
|
|
|
|
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]
|
|
|
|
|
testQualities = qualitiesString.split(',')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quality = DEFAULT_QUALITY
|
|
|
|
|
qualityTokens = [q for q in sys.argv if q.startswith('q=')]
|
|
|
|
|
if qualityTokens:
|
|
|
|
@ -116,39 +155,59 @@ outputTokens = ['-f', 'webm', outputFilename]
|
|
|
|
|
|
|
|
|
|
nullTokens = ['-f', 'null', '/dev/null']
|
|
|
|
|
|
|
|
|
|
av1Tokens = ['-c:v:0',
|
|
|
|
|
'libsvtav1',
|
|
|
|
|
'-svtav1-params',
|
|
|
|
|
f"crf={quality}:preset={preset}:tune=0:enable-overlays=1:scd=1:scm=0",
|
|
|
|
|
'-pix_fmt', 'yuv420p10le']
|
|
|
|
|
|
|
|
|
|
vp9Pass1Tokens = ['-c:v:0', 'libvpx-vp9', '-row-mt', '1',
|
|
|
|
|
'-crf', str(quality), '-pass', '1', '-speed', '4',
|
|
|
|
|
'-frame-parallel', '0', '-g', '9999', '-aq-mode', '0']
|
|
|
|
|
testTokens = ['-ss', '60', '-t', '180']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if testQualities:
|
|
|
|
|
|
|
|
|
|
for testQ in testQualities:
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
vp9Pass2Tokens = ['-c:v:0', 'libvpx-vp9', '-row-mt', '1',
|
|
|
|
|
'-crf', str(quality), '-pass', '2',
|
|
|
|
|
'-frame-parallel', '0', '-g', '9999', '-aq-mode', '0',
|
|
|
|
|
'-auto-alt-ref', '1', '-lag-in-frames', '25']
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
|
|
if targetFormat == 'av1':
|
|
|
|
|
if targetFormat == 'av1':
|
|
|
|
|
|
|
|
|
|
commandSequence = commandTokens + mappingTokens + av1Tokens + audioTokens + outputTokens
|
|
|
|
|
commandSequence = commandTokens + mappingTokens + generateAV1Tokens(quality, preset) + audioTokens + generateOutputTokens(outputFilename)
|
|
|
|
|
|
|
|
|
|
print(f"Command Sequence: {commandSequence}")
|
|
|
|
|
|
|
|
|
|
executeProcess(commandSequence)
|
|
|
|
|
|
|
|
|
|
if targetFormat == 'vp9':
|
|
|
|
|
if targetFormat == 'vp9':
|
|
|
|
|
|
|
|
|
|
commandSequence1 = commandTokens + vp9Pass1Tokens + audioTokens + nullTokens
|
|
|
|
|
commandSequence1 = commandTokens + generateVP9Pass1Tokens(quality) + audioTokens + nullTokens
|
|
|
|
|
|
|
|
|
|
print(f"Command Sequence 1: {commandSequence1}")
|
|
|
|
|
|
|
|
|
|
executeProcess(commandSequence1)
|
|
|
|
|
|
|
|
|
|
commandSequence2 = commandTokens + mappingTokens + vp9Pass2Tokens + audioTokens + outputTokens
|
|
|
|
|
commandSequence2 = commandTokens + mappingTokens + generateVP9Pass2Tokens(quality) + audioTokens + generateOutputTokens(outputFilename)
|
|
|
|
|
|
|
|
|
|
print(f"Command Sequence 2: {commandSequence2}")
|
|
|
|
|
|
|
|
|
|