PyAV icon indicating copy to clipboard operation
PyAV copied to clipboard

PyAV should be able to use ffmpeg support for output to RTMP/SRT protocols

Open zubindittia opened this issue 3 years ago • 0 comments

Overview

PyAV should support output to URLs for RTMP and SRT (these are supported by ffmpeg).

Desired Behavior

Currently, the av.open() function appears to only support writing to file or file-like objects. If we pass a RTMP or SRT url as the 'file' argument to av.open(), it does not seem to work. Specifically, if we use a RTMP URL with video codec set to flv, or a SRT URL with video codec set to mpegts, then we seem to be outputting to the URL even if the URL corresponds to a server that does not exist. For example, if we output flv video to rtmp://127.0.0.1:1234/foo and there is no server running at that URL, the output goes to a black hole and there is no indication that we could not connect to that server (ffmpeg reports a connect error in the same situation).

Example API

Ideally, just replacing the file in av.open() with an output URL should work seamlessly, and we should be able to find out if there was an error connecting to the server:

output_container = av.open('rtmp://127.0.0.1:1234/foo', 'w', format = 'flv') output_container = av.open('srt://127.0.0.1:1234/foo', 'w', format = 'mpegts')

When we start outputting frames to the container is when presumably libav is trying to connect to the server, and if there is an error at that point, the output should fail or an exception should be thrown.

Additional context

zubindittia avatar Jul 19 '22 13:07 zubindittia