PyAv save audio and video togerther from stream to simple file

612 Views Asked by At

Based on the examples from the documentation, I am trying to implement the recording of a stream in an .mp4 file. I can't start saving to a file both sound and video at the same time. Something one :)

import av.datasets
from av.container import InputContainer, OutputContainer

input_: InputContainer = av.open("udp://192.168.1.68:8083?pkt_size=1316&overrun_nonfatal=1&fifo_size=50000000")
output: OutputContainer = av.open("remuxed.mkv", "w")

in_stream = input_.streams.get(audio=(0,), video=0)

out_stream = output.add_stream(template=in_stream)
for packet in input_.demux(in_stream):

    if packet.dts is None:
        continue

    packet.stream = out_stream

    output.mux(packet)

input_.close()
output.close()

https://pyav.org/docs/develop/cookbook/basics.html

Help me how can I do this? At the moment, it is possible to record either audio or video.

Thank you in advance

0

There are 0 best solutions below