From d864cffb79583c6232d780d0aa5fe504982d2fa0 Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Sat, 21 Jan 2023 11:36:00 -0500 Subject: [PATCH 1/4] Add test for validity of stream.type --- tests/test_streams.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_streams.py b/tests/test_streams.py index beab831ba..efee029dc 100644 --- a/tests/test_streams.py +++ b/tests/test_streams.py @@ -1,4 +1,5 @@ import av +from fractions import Fraction from .common import TestCase, fate_suite @@ -27,3 +28,21 @@ def test_selection(self): self.assertEqual([video], container.streams.get(video=(0,))) # TODO: Find something in the fate suite with video, audio, and subtitles. + + def test_stream_properties(self): + # Ensure that all stream properties have sensible values even + # if writing to the stream hasn't started yet + with av.open(self.sandboxed("output.mp4"), "w") as container: + stream = container.add_stream('h264') + assert stream.id is not None + assert stream.profile is None + assert stream.index == 0 + assert stream.time_base is None + assert stream.average_rate == Fraction(24, 1) + assert stream.base_rate is None + assert stream.guessed_rate is None + assert stream.start_time is None + assert stream.duration is None + assert stream.frames == 0 + assert stream.language is None + assert stream.type is None From eae7372569c164a9c951447da7f80eb814c4bfee Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Wed, 1 Feb 2023 20:50:21 -0500 Subject: [PATCH 2/4] isort --- tests/test_streams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_streams.py b/tests/test_streams.py index efee029dc..f2cda99bc 100644 --- a/tests/test_streams.py +++ b/tests/test_streams.py @@ -1,6 +1,6 @@ -import av from fractions import Fraction +import av from .common import TestCase, fate_suite From 1eaebd44dbffc011fc52448749e20c3e094614b4 Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Wed, 1 Feb 2023 20:51:31 -0500 Subject: [PATCH 3/4] Fix stream type --- tests/test_streams.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_streams.py b/tests/test_streams.py index f2cda99bc..a5ff8e59a 100644 --- a/tests/test_streams.py +++ b/tests/test_streams.py @@ -45,4 +45,4 @@ def test_stream_properties(self): assert stream.duration is None assert stream.frames == 0 assert stream.language is None - assert stream.type is None + assert stream.type == 'video' From a34431cc142cde4295009c71d15ce3693304b97d Mon Sep 17 00:00:00 2001 From: Mark Harfouche Date: Wed, 1 Feb 2023 21:06:55 -0500 Subject: [PATCH 4/4] isort --- tests/test_streams.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_streams.py b/tests/test_streams.py index a5ff8e59a..b6f3b9a15 100644 --- a/tests/test_streams.py +++ b/tests/test_streams.py @@ -1,6 +1,7 @@ from fractions import Fraction import av + from .common import TestCase, fate_suite