Eittipat / pyrtmp

PyRTMP: Pure Python RTMP server
MIT License
90 stars 20 forks source link

How to manipulate the stream in real time? #10

Open guangjieguo opened 10 months ago

guangjieguo commented 10 months ago

Hi,

I am using pyrtmp for a rtmp server. It works great for video upstream and save it as a flv file. But I want to manipulate the frames in real time. How can I do that?

Thank you!

Jack Guo

Eittipat commented 10 months ago

You have to pass video frame into video processor. For example OpenCV or ffmpeg and do whatever you want. Remember that video frame you received is chunk of compressed video stream not a still image

This is example of piping video stream into ffmpeg https://github.com/Eittipat/pyrtmp/blob/master/example/demo_ffmpeg.py OpenCV can be done in the same way

guangjieguo commented 9 months ago

@Eittipat Thank you for your kind reply. I still don't know how to customize your code to extract frames. I don't know which variable contains the latest chunk of stream and how to decode the chunk into frames. Would you update an example that can extract frames and show them without saving the stream into a flv file, please? That will be very helpful to me. Thank you very much.

Jack Guo

xiaolaohu123wf commented 5 months ago

@Eittipat Thank you for your kind reply. I still don't know how to customize your code to extract frames. I don't know which variable contains the latest chunk of stream and how to decode the chunk into frames. Would you update an example that can extract frames and show them without saving the stream into a flv file, please? That will be very helpful to me. Thank you very much.

Jack Guo

There is a specific definition of frame in on_video_message, but I'm still trying to change it to work with OpenCV

Eittipat commented 5 months ago

Hi @guangjieguo @xiaolaohu123wf

I will create OpenCV example may be this weekend.

Thank you for using this library

xiaolaohu123wf commented 4 months ago

Hi @guangjieguo @xiaolaohu123wf

I will create OpenCV example may be this weekend.

Thank you for using this library

Thank you very much for your contribution!

guangjieguo commented 4 months ago

Hi @guangjieguo @xiaolaohu123wf

I will create OpenCV example may be this weekend.

Thank you for using this library

It will be very convenient for us. Thank you so much!