The prod iGPU has no VC-1 Advanced decode ("No support for codec vc1 profile 3"), so every VC-1
session died on the GPU and fell back to libx264, which needs ~17 s for the three warm-up segments:
a start or a seek took ~19.5 s. VC-1, XviD and DivX now take CPU decode -> hwupload -> h264_vaapi
(three segments in 5.5 s for a 1080p VC-1 remux, measured on prod hardware with this argv).
The transcode_hw facet now says whether the GPU encodes: VC-1/XviD/DivX count, and so does an HDR
film (the OpenCL tonemap runs on the GPU; the facet said software). Migration 0119 rewrites the
stored facet and re-queues 10-bit items for the HDR probe.
71 lines
2.7 KiB
Python
71 lines
2.7 KiB
Python
"""Migration 0119's data step, DB-lane: the stored `transcode_hw` facet follows the rule that it says
|
|
whether the GPU does the encode, and a 10-bit decodable item is probed again so its HDR flag decides.
|
|
|
|
The schema half is checked by test_migrations.py; a facet value left stale is invisible there.
|
|
"""
|
|
|
|
from alembic import command
|
|
from alembic.config import Config
|
|
from sqlalchemy import text
|
|
|
|
from app.db import engine
|
|
|
|
|
|
def test_the_stored_facet_is_rewritten_by_the_gpu_encode_rule(db):
|
|
cfg = Config("alembic.ini")
|
|
command.downgrade(cfg, "0118_videos_shuffle_key")
|
|
try:
|
|
with engine.begin() as conn:
|
|
lib = conn.execute(
|
|
text(
|
|
"INSERT INTO plex_libraries (plex_key, title, kind, enabled)"
|
|
" VALUES ('m1', 'Movies', 'movie', true) RETURNING id"
|
|
)
|
|
).scalar_one()
|
|
|
|
def item(key, playable, codec, hw, depth=None, probed=False):
|
|
conn.execute(
|
|
text(
|
|
"INSERT INTO plex_items (rating_key, library_id, kind, title, playable,"
|
|
" codec_video, transcode_hw, video_bit_depth, media_probed_at)"
|
|
" VALUES (:k, :l, 'movie', :k, :p, :c, :hw, :d,"
|
|
" CASE WHEN :pr THEN now() END)"
|
|
),
|
|
{
|
|
"k": key,
|
|
"l": lib,
|
|
"p": playable,
|
|
"c": codec,
|
|
"hw": hw,
|
|
"d": depth,
|
|
"pr": probed,
|
|
},
|
|
)
|
|
|
|
item("vc1", "transcode", "VC1", True, 8, probed=True) # the old list said decodable
|
|
item("xvid", "transcode", "mpeg4", False)
|
|
item("divx", "transcode", "msmpeg4v3", False)
|
|
item("av1", "transcode", "av1", False)
|
|
item("h8", "transcode", "hevc", True, 8, probed=True)
|
|
item("h10", "transcode", "hevc", False, 10, probed=True) # SDR or HDR: unknown here
|
|
item("remux", "remux", "h264", None)
|
|
finally:
|
|
command.upgrade(cfg, "head")
|
|
|
|
with engine.connect() as conn:
|
|
rows = {
|
|
k: (hw, probed)
|
|
for k, hw, probed in conn.execute(
|
|
text("SELECT rating_key, transcode_hw, media_probed_at IS NOT NULL FROM plex_items")
|
|
).tuples()
|
|
}
|
|
assert rows == {
|
|
"vc1": (True, True),
|
|
"xvid": (True, False),
|
|
"divx": (True, False),
|
|
"av1": (False, False),
|
|
"h8": (True, True),
|
|
"h10": (False, False), # re-queued: the probe reads its HDR flag again
|
|
"remux": (None, False),
|
|
}
|