Skip to content

Instantly share code, notes, and snippets.

@nico-lab
Created April 30, 2025 11:50
Show Gist options
  • Save nico-lab/c133ab19f79deb7bf364ae3f197335c8 to your computer and use it in GitHub Desktop.
Save nico-lab/c133ab19f79deb7bf364ae3f197335c8 to your computer and use it in GitHub Desktop.
libvmafでcsv出力したログをsendcmd、drawtextフィルタで表示する
import csv
FRAME_RATE = 24000/1001 # Or any fractional frame rate you need
# Load the CSV file and process it
with open('vmaf.csv', 'r') as csvfile, open('filter.txt', 'w') as outfile:
reader = csv.reader(csvfile)
header = next(reader) # Get the header row
# Find the indices of the columns
Frame_col_index = header.index('Frame')
cambi_col_index = header.index('cambi')
vmaf_col_index = header.index('vmaf')
vmaf_neg_col_index = header.index('vmaf_neg')
for row in reader:
Frame = int(row[Frame_col_index])
pts = Frame / float(FRAME_RATE)
cambi = float(row[cambi_col_index])
vmaf = float(row[vmaf_col_index])
vmaf_neg = float(row[vmaf_neg_col_index])
outfile.write(f"{pts:05.6f} [enter] drawtext reinit text=Frame\\\:{Frame}\\ cambi\\\:{cambi:.6f}\\ vmaf\\\:{vmaf:.6f}\\ vmaf_neg\\\:{vmaf_neg:.6f};\n")
print('The result is saved in filter.txt')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment