Synchronizing two MPEG-4 streams

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
rasmus
New Cone
New Cone
Posts: 4
Joined: 11 Sep 2008 21:11

Synchronizing two MPEG-4 streams

Postby rasmus » 17 Nov 2008 09:50

Hi!

I'm developing an application that should be able to play two different MPEG-4 streams next to each other. In addition, the two streams should be synchronized (i.e. they should both display frame #n at the same time).

I've used wxWidgets and libVLC to create the GUI and play the videos, but my challenge now is the sync. As of now, I use the libvlc_media_player_play() command to first start playing video 1 and then video 2. This causes a slight delay for video 2 compared to video 1, a delay which may vary slightly each time I run the application.

Does anyone know if I would be able to solve this task using libvlc, or does anyone know of any other way to do this (not including libvlc at all)?


Thank you for your help!

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Synchronizing two MPEG-4 streams

Postby Jean-Baptiste Kempf » 17 Nov 2008 11:18

Well, try latest VLC (or devel 1.0) and try vlc file.mp4 --input-slave file2.mp4.

If that works, then do it with libVLC.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

rasmus
New Cone
New Cone
Posts: 4
Joined: 11 Sep 2008 21:11

Re: Synchronizing two MPEG-4 streams

Postby rasmus » 18 Nov 2008 19:22

Well, try latest VLC (or devel 1.0) and try vlc file.mp4 --input-slave file2.mp4.

If that works, then do it with libVLC.
Thank you for your input, J-B! Your suggestion works, however I'm having some difficulties achieveing the desired look in my application.

I create a new VLC instance and draw the video output at the appropriate position in the GUI with this code:

Code: Select all

myarg0 = "-I"; myarg1 = "dummy"; myarg2 = "--plugin-path=.\\plugins"; myarg4 = "--input-slave=C:\\Users\\Rasmus\\Desktop\\videos\\test_12345.avi"; char *myargs2[6] = {myarg0, myarg1, myarg2, myarg4, NULL}; libvlc_media_t *m1, *m2; VLC_exception_init(&excp1); inst1 = VLC_new(4, myargs2, &excp1); video_panel1 = new wxPanel(this, -1); video_panel1->SetInitialSize(wxSize((this->GetSize().GetWidth())/2, (this->GetSize().GetHeight())/2)); HWND vlc_canvas_hwnd1 = reinterpret_cast<HWND>(video_panel1->GetHWND()); libvlc_drawable_t vlc_canvas1 = reinterpret_cast<libvlc_drawable_t>(vlc_canvas_hwnd1); player1 = VLC_media_player_new(inst1, &excp1); VLC_media_player_set_drawable(player1, vlc_canvas1, &excp1); filename1 = "C:\\Users\\Rasmus\\Desktop\\videos\\test_abcde.avi"; m1 = VLC_media_new(inst1, filename1, &excp1); VLC_media_player_set_media(player1, m1, &excp1); sizer->Add(video_panel1, 0, wxALL|wxEXPAND, 0);
However, when the "--input-slave" option is included in the creation of the VLC instance, both videos (test_abcde.avi and test_12345.avi) are displayed at the same position in the GUI. If I drop the line "VLC_media_player_set_drawable(player1, vlc_canvas1, &excp1);", the videos are not displayed in the GUI, but in two new windows that pop up.


Anyone got any ideas on how to display the videos at two different places in the GUI?

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Synchronizing two MPEG-4 streams

Postby Jean-Baptiste Kempf » 18 Nov 2008 23:51

no, do something like setoptions
and use :input-slave after filename1.
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.

rasmus
New Cone
New Cone
Posts: 4
Joined: 11 Sep 2008 21:11

Re: Synchronizing two MPEG-4 streams

Postby rasmus » 20 Nov 2008 20:16

no, do something like setoptions
and use :input-slave after filename1.

Cheers, J-B!

I now have the two video files playing in sync in my GUI!
This did the trick:

Code: Select all

char *myargs3 = "--input-slave=C:\\Users\\Rasmus\\Desktop\\videos\\test_abcde.mp4"; VLC_media_add_option(m1, myargs3, &excp1);

Jean-Baptiste Kempf
Site Administrator
Site Administrator
Posts: 37523
Joined: 22 Jul 2005 15:29
VLC version: 4.0.0-git
Operating System: Linux, Windows, Mac
Location: Cone, France
Contact:

Re: Synchronizing two MPEG-4 streams

Postby Jean-Baptiste Kempf » 20 Nov 2008 22:06

Great!
Jean-Baptiste Kempf
http://www.jbkempf.com/ - http://www.jbkempf.com/blog/category/Videolan
VLC media player developer, VideoLAN President and Sites administrator
If you want an answer to your question, just be specific and precise. Don't use Private Messages.


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 196 guests