Skip to content
Advertisement

Pipe and OpenCV to FFmpeg with audio streaming RTMP in Python

I’m trying to stream FFmpeg with audio.
I will show my code below:


Import module

JavaScript

Create variables

JavaScript

Command param

JavaScript

Create subprocess to ffmpeg command

JavaScript

Send frame to RTMP server

JavaScript

I hope you can help me to be able to live stream via FFmpeg over RTMP with audio. Thanks!

Advertisement

Answer

Assuming you actually need to use OpenCV for the video, you have to add the audio directly to FFmpeg as Gyan commented, because OpenCV does not support audio.

-re argument is probably required for live streaming.


For testing, I modified the RTMP URL from YouTube to localhost.
FFplay sub-process is used for capturing the stream (for testing).

Complete code sample:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement