-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_encoding_stats.py
More file actions
72 lines (63 loc) · 2.14 KB
/
plot_encoding_stats.py
File metadata and controls
72 lines (63 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import pandas as pd
import matplotlib.pyplot as plt
import re
import argparse
# -------------------------------
# 1. Parse command-line arguments
# -------------------------------
parser = argparse.ArgumentParser(description="Plot encoding statistics from a CSV file")
parser.add_argument("csv_file", help="Path to the CSV file containing encoding results")
args = parser.parse_args()
csv_file = args.csv_file
# -------------------------------
# 2. Load and prepare the data
# -------------------------------
df = pd.read_csv(csv_file, sep=",") # adjust sep="," if needed
# Convert 'size' to numeric (KB -> float)
df["size"] = df["size"].str.replace(" KB", "", regex=False).astype(float)
# Function to convert "00:00:03:150:353" to seconds (approx)
def parse_time(t):
parts = re.split("[:]", t)
if len(parts) == 5:
h, m, s, ms, us = map(int, parts)
return h*3600 + m*60 + s + ms/1000 + us/1e6
else:
return None
df["walltime_sec"] = df["walltime"].apply(parse_time)
df["usertime_sec"] = df["usertime"].apply(parse_time)
# -------------------------------
# 3. Sort data by quality
# -------------------------------
df_sorted = df.sort_values(by="quality")
# -------------------------------
# 4. Basic statistics
# -------------------------------
basic_stats = {
"size_min": df["size"].min(),
"size_max": df["size"].max(),
"vmaf_min": df["vmaf_mean"].min(),
"vmaf_max": df["vmaf_mean"].max(),
"encoding_time_min": df["walltime_sec"].min(),
"encoding_time_max": df["walltime_sec"].max()
}
# -------------------------------
# 5. Graphs
# -------------------------------
# Relative size vs quality
plt.figure(figsize=(6,4))
plt.plot(df_sorted["quality"], df_sorted["ratio_size"], marker="o", label="Relative Size")
plt.xlabel("Quality Factor (CQ)")
plt.ylabel("Size Ratio")
plt.title("Relative Size vs CQ")
plt.legend()
plt.grid(True)
plt.show()
# Average VMAF vs quality
plt.figure(figsize=(6,4))
plt.plot(df_sorted["quality"], df_sorted["vmaf_mean"], marker="o", color="green", label="Average VMAF")
plt.xlabel("Quality Factor (CQ)")
plt.ylabel("VMAF Score")
plt.title("Average VMAF vs CQ")
plt.legend()
plt.grid(True)
plt.show()