Editing raw frames before output

This forum is about all development around libVLC.
photohunter
New Cone
New Cone
Posts: 2
Joined: 19 Jan 2018 15:24

Editing raw frames before output

Postby photohunter » 19 Jan 2018 16:31

Hi everyone!

I'm working on a project in which I need to capture a live video stream, apply colourful filters to the frames and then re-stream it forward all in real time. I started implementing this with OpenCV, with which i managed to capture and edit the frames easily, but I couldn't find a way to stream it further. In my research I found out about libVLC and managed to get a simple capture and re-stream working by looking at the Streaming HowTo on VideoLAN Wiki. My code looked something like this:

Code: Select all

libvlc_instance_t *vlc; libvlc_media_player_t *mediaPlayer; libvlc_media_t *media; media = libvlc_media_new_location(vlc, "https://mnmedias.api.telequebec.tv/m3u8/29880.m3u8"); libvlc_media_add_option(media, ":sout=#standard{mux=ts,dst=:8090,access=http}"); mediaPlayer = libvlc_media_player_new_from_media(media); libvlc_media_player_play(mediaPlayer); sleep(60); libvlc_media_player_stop(mediaPlayer); libvlc_media_release(media); libvlc_media_player_release(mediaPlayer); libvlc_release(libvlc);

The problem is I can't find a way to access the frames before they are re-streamed. I tried custom callbacks for mediaPlayer to get the frames rendered to custom memory but when I changed it, it didn't seem to have any effect on the re-streamed video. From this I figured out that mediaPlayer probably ignores what I do with the rendered data and uses the original input instead, because the sout option is set for media, not mediaPlayer (am I correct?). So I created another media and mediaPlayer, and defined custom callbacks for the media, so that I can supply it with the edited frames, and it should then stream it. When I tried this, I got an error on the recieving side stating core stream error: cannot pre fill buffer. I wrote just the read callback according to documentation, because I didn't need to allocate, deallocate, or seek the stream (it will be a live stream).

With similar results, I tried doing this with imem. (I couldn't find any documentation so I used the example here.

I don't usually post on forums, because most of the times, after enough digging I can figure things out. I've been struggling with this problem for weeks, though, and I would really appreciate any help on how to solve this. Thanks! :)

Rémi Denis-Courmont
Developer
Developer
Posts: 15266
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Editing raw frames before output

Postby Rémi Denis-Courmont » 19 Jan 2018 21:25

1) Yes.
2) That most typically means that you are not returning any data.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

photohunter
New Cone
New Cone
Posts: 2
Joined: 19 Jan 2018 15:24

Re: Editing raw frames before output

Postby photohunter » 22 Jan 2018 17:37

Thanks for the reply. Unfortunately, I couldn't get it working. I checked the frame I get in the media player video unlock callback and it seems to be correct. I just can't get to stream it from the memory. I'm using the media_new_callbacks API and I even tried implementing all of the callbacks although, as I mentioned, I'm capturing a live stream and therefore seeking is not needed. Besides the error on client side I also get this error on the server side:
imem demux error: Invalid get/release function pointers
I have no idea why since I defined all of the callbacks (open, read, seek, close).

What format should the data passed in the read media callback be? Can it be RV24 as I get from the input media player? Why does the read callback sometimes want a different amount of data?

Sorry if these are noob questions but I can't figure out what I'm doing wrong... :(


Return to “Development around libVLC”

Who is online

Users browsing this forum: Rémi Denis-Courmont and 14 guests