How to read multiple video tracks in memory ?
Posted: 21 May 2015 12:44
Hello, i'm using libvlc 2.0.8 on Ubuntu and I'm trying to read a file with 2 video tracks. The goal is to recompose the frame from track 1 with the frame from track 2.
Right now I'm able to select which track to read with libvlc_video_set_track and save frames in memory by setting my own callbacks with libvlc_video_set_callbacks
My question is how can I read both tracks at the same time ?
Do I have to set different callbacks for each track or are they handled by one callback ? I tried both cases without success.
1. Different callbacks for each track (pseudo code):
It seems like only the last set of callbacks are taken into account.
2. One set of callbacks for both tracks (pseudo code):
Although libvlc_video_get_track always returns the same track id, the frames stored in myfifo are actually from track 1 and 2. So how can I know exactly where the decoded frame came from ?
Any help is appreciated, thanks !
Right now I'm able to select which track to read with libvlc_video_set_track and save frames in memory by setting my own callbacks with libvlc_video_set_callbacks
My question is how can I read both tracks at the same time ?
Do I have to set different callbacks for each track or are they handled by one callback ? I tried both cases without success.
1. Different callbacks for each track (pseudo code):
Code: Select all
libvlc_video_set_track(0)
libvlc_video_set_callbacks(lock_cb0, display_cb_0, unlock_cb0)
libvlc_video_set_track(1)
libvlc_video_set_callbacks(lock_cb1, display_cb_1, unlock_cb1)
2. One set of callbacks for both tracks (pseudo code):
Code: Select all
display_cb(void *opaque, void *picture)
{
print libvlc_video_get_track() // always returns the same track id.
myfifo.push(picture)
}
Any help is appreciated, thanks !