Skip to content

Commit

Permalink
I need a beer
Browse files Browse the repository at this point in the history
  • Loading branch information
WyattBlue committed Nov 20, 2024
1 parent c72335f commit 502e414
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
20 changes: 7 additions & 13 deletions av/container/output.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,15 @@ cdef class OutputContainer(Container):
:param template: Copy codec from another :class:`~av.stream.Stream` instance.
:param \\**kwargs: Set attributes for the stream.
:rtype: The new :class:`~av.stream.Stream`.
"""
cdef const lib.AVCodec *codec
cdef Codec codec_obj

if not template.codec_context:
raise ValueError("template has no codec context")

cdef Codec codec_obj = Codec(template.codec_context.codec.name, "w")
cdef const lib.AVCodec *codec = codec_obj.ptr
if template.type == "subtitle":
codec_obj = template.codec_context.codec
else:
codec_obj = Codec(template.codec_context.codec.name, "w")
codec = codec_obj.ptr

# Assert that this format supports the requested codec.
if not lib.avformat_query_codec(self.ptr.oformat, codec.id, lib.FF_COMPLIANCE_NORMAL):
Expand Down Expand Up @@ -182,13 +183,6 @@ cdef class OutputContainer(Container):
cdef Stream py_stream = wrap_stream(self, stream, py_codec_context)
self.streams.add_stream(py_stream)

if template.type == "video":
py_stream.time_base = kwargs.pop("time_base", 1 / template.average_rate)
elif template.type == "audio":
py_stream.time_base = kwargs.pop("time_base", 1 / template.rate)
else:
py_stream.time_base = kwargs.pop("time_base", Fraction(0, 1))

for k, v in kwargs.items():
setattr(py_stream, k, v)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def test_subtitle_muxing(self) -> None:

output.close()
output_bytes.seek(0)
# assert output_bytes.getvalue() == b""
assert output_bytes.getvalue().startswith(b'\x00\x00\x00\x1cftypisom\x00\x00\x02\x00isomiso2mp41\x00\x00\x00\x08free')


class TestEncodeStreamSemantics(TestCase):
Expand Down

0 comments on commit 502e414

Please sign in to comment.