@@ -35,6 +35,41 @@ def test_selection(self) -> None:
3535 data = container .streams .data [0 ]
3636 assert data == container .streams .best ("data" )
3737
38+ def test_printing_closed_video_stream (self ) -> None :
39+ input_ = av .open (
40+ fate_suite ("amv/MTV_high_res_320x240_sample_Penguin_Joke_MTV_from_WMV.amv" )
41+ )
42+ container = av .open ("out.mkv" , "w" )
43+
44+ video_stream = container .add_stream ("h264" , rate = 30 )
45+ # encoder = video_stream.codec.name + ""
46+
47+ video_stream .width = input_ .streams .video [0 ].width
48+ video_stream .height = input_ .streams .video [0 ].height
49+ video_stream .pix_fmt = "yuv420p"
50+
51+ for frame in input_ .decode (video = 0 ):
52+ container .mux (video_stream .encode (frame ))
53+ break
54+
55+ encoder = "libx264"
56+ repr = f"{ video_stream } "
57+ assert repr .startswith (f"<av.VideoStream #0 { encoder } , yuv420p 160x120 at " )
58+ assert repr .endswith (">" )
59+
60+ # repr = f"{video_stream}"
61+ # assert repr.startswith(f"<av.VideoStream #0 {encoder}, yuv420p 160x120 at ")
62+ # assert repr.endswith(">")
63+
64+ video_stream .close ()
65+
66+ repr = f"{ video_stream } "
67+ assert repr .startswith (f"<av.VideoStream #0 { encoder } , yuv420p 0x0 at " )
68+ assert repr .endswith (">" )
69+
70+ container .close ()
71+ input_ .close ()
72+
3873 # def test_side_data(self) -> None:
3974 # container = av.open(fate_suite("mov/displaymatrix.mov"))
4075 # video = container.streams.video[0]
0 commit comments