"""A generated moving-shape video for integration checks, never baseball validation.""" from fractions import Fraction import sys import av import numpy as np def make_fixture(path): with av.open(str(path), "w") as output: stream = output.add_stream("libx264", rate=30) stream.width, stream.height, stream.pix_fmt = 320, 240, "yuv420p" stream.time_base = Fraction(1,1000) stream.codec_context.time_base = Fraction(1,1000) stream.options = {"bf":"0", "crf":"18"} for i in range(30): image = np.full((240,320,3), 30+i, np.uint8) image[80:160, 60+i*3:100+i*3] = [50,180,230] frame = av.VideoFrame.from_ndarray(image, format="bgr24") frame.pts, frame.time_base = round(i*1000/30), Fraction(1,1000) for packet in stream.encode(frame): output.mux(packet) for packet in stream.encode(): output.mux(packet) if __name__ == "__main__": make_fixture(sys.argv[1])