Complete VIDEO-001 through VIDEO-004 software video studies
This commit is contained in:
45
tools/video004_keyframe.py
Normal file
45
tools/video004_keyframe.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""Контроль одной и двух потерь источников опорного кадра H.264."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from tools.video004_transport import (
|
||||
BASELINE_160, BASELINE_320, CODEC_RESULTS, OUTPUT, _frames, simulate,
|
||||
)
|
||||
|
||||
|
||||
DEFAULT_OUTPUT = OUTPUT.with_name("keyframe_recovery.json")
|
||||
|
||||
|
||||
def run() -> dict:
|
||||
codec = json.loads(CODEC_RESULTS.read_text(encoding="utf-8"))
|
||||
baseline = json.loads(BASELINE_320.read_text(encoding="utf-8"))
|
||||
baseline_160 = json.loads(BASELINE_160.read_text(encoding="utf-8"))
|
||||
cases = []
|
||||
for window in baseline["windows"]:
|
||||
combined, _ = _frames("NORMAL", 640, 360, 10, window, codec, baseline_160)
|
||||
frames = [frame for frame in combined if frame.stream_id == 0x56303334]
|
||||
for rate in ("2/3", "3/4"):
|
||||
for k, r, boost in ((8, 1, False), (8, 1, True), (8, 2, False)):
|
||||
for kind, count in (("keyframe", 1), ("keyframe_double", 2)):
|
||||
item = simulate(frames, 10, rate, k, r, (kind, count), boost)
|
||||
item["window"] = window["name"]
|
||||
cases.append(item)
|
||||
return {"source_sha256": codec["source_sha256"], "cases": cases, "rf_tx": 0}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--output", type=Path, default=DEFAULT_OUTPUT)
|
||||
args = parser.parse_args()
|
||||
result = run()
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.output.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
|
||||
print(f"VIDEO-004: {len(result['cases'])} случаев потери опорного кадра; {args.output}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user