Automatically determine container format based on codec #1529
|
Hi all, I was wondering if there is a way to programmatically determine the output container format based on the input media codec when transcoding? My use case is that I am trying to extract the audio streams from various types of media and store these in an I've considered creating a conversion table storing Here is the code I am using: buffer = io.BytesIO()
with av.open("./media.mp4", "r") as container:
a_stream = container.streams.audio[0]
codec = a_stream.codec.name
rate = a_stream.rate
layout = a_stream.layout.name
## NEEDS IMPLEMENTED
format = "some_container_format"
with av.open(buffer, format=format, "w") as o_container:
o_stream = o_container.add_stream(codec, layout=layout, rate=rate)
for frame in container.decode(a_stream):
for packet in o_stream.encode(frame):
o_container.mux(packet)
for packet in o_stream.encode(None):
o_container.mux(packet) |
Answered by
WyattBlue
Sep 15, 2024
Replies: 1 comment 1 reply
|
There isn't one. That's because you can store all audio codecs in the matroska format (mkv) |
1 reply
Answer selected by
WyattBlue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There isn't one. That's because you can store all audio codecs in the matroska format (mkv)