GStreamer in double loop

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

GStreamer in double loop

Jeffrey Barish
GStreamer requires gobject.  gobject runs in a loop, normally by calling the
run method on the main loop.  That loop blocks until there is something to
do.  I also need to monitor sockets over which I send commands about what
GStreamer is supposed to do.  Normally, it runs in a loop that blocks until
a command arrives on a socket.  It is not possible to run both of these
loops in the same thread using the normal procedure because they both
block.  One possibility is to perform the looping manually.  gobject has a
method that makes it possible to perform an iteration of the context.  I
could check the sockets and then perform an iteration that blocks.  I would
repeat those two steps every time a message arrives from gobject.  But
there are long periods when no messages arrive, so I could be missing
commands that have arrived on a socket while I am waiting for a GStreamer
message.  If I make the iteration nonblocking, then the loop will buzz too
quickly and the CPU load will go to 100%.  If I put in a sleep, I can get
the CPU load under control, but then I will be missing both GStreamer
messages and socket commands while sleeping.  If I block on the socket
access, I could be tardy in responding to GStreamer messages.  So this
approach doesn't work.

The only possibility, I believe, is to use multithreading.  The socket
polling goes in one thread and the gobject loop goes in another.  Both
threads send commands to playbin2 through a thread-safe queue.  A third
thread gets from the queue and blocks whenever nothing is there.  With this
approach, the moment a message arrives from gobject or a command arrives
from a socket, the appropriate command is put in the queue and the thread
reading the queue wakes to execute it.  Response time should be low in both
cases.

I have implemented this solution.  It works fine on the socket side.
However, whenever I use the run method of the GObject maincontext, the
program hangs.  If I run the GObject loop using the manual method and stick
in a 1-second sleep, it works fine, so I know that I have the queue and
related code working correctly.  However, I cannot use the manual solution
because the response time could be too high because of the sleep.  I am
stymied by the GObject problem.  I should perhaps post a message to the gtk
mailing list, but I was wondering whether any other GStreamer users have
ever encountered a problem that required fast response to two loops and
what solutions you might have found.  If anyone knows multithreading,
perhaps you could suggest things that might cause the GObject loop to hang.
--
Jeffrey Barish


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GStreamer in double loop

Jan Schmidt-6
On Thu, 2009-06-18 at 10:21 -0600, Jeffrey Barish wrote:

> GStreamer requires gobject.  gobject runs in a loop, normally by calling the
> run method on the main loop.  That loop blocks until there is something to
> do.  I also need to monitor sockets over which I send commands about what
> GStreamer is supposed to do.  Normally, it runs in a loop that blocks until
> a command arrives on a socket.  It is not possible to run both of these
> loops in the same thread using the normal procedure because they both
> block.  One possibility is to perform the looping manually.  gobject has a
> method that makes it possible to perform an iteration of the context.  I
> could check the sockets and then perform an iteration that blocks.  I would
> repeat those two steps every time a message arrives from gobject.  But
> there are long periods when no messages arrive, so I could be missing
> commands that have arrived on a socket while I am waiting for a GStreamer
> message.  If I make the iteration nonblocking, then the loop will buzz too
> quickly and the CPU load will go to 100%.  If I put in a sleep, I can get
> the CPU load under control, but then I will be missing both GStreamer
> messages and socket commands while sleeping.  If I block on the socket
> access, I could be tardy in responding to GStreamer messages.  So this
> approach doesn't work.

You can use GLib's GIOChannel API to register the socket file
descriptor, and get the GObject mainloop to poll it for you efficiently.

See g_io_channel_unix_new () and g_io_add_watch ()

Cheers,
Jan.
--
Jan Schmidt <[hidden email]>


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GStreamer in double loop

Jeffrey Barish
Jan Schmidt wrote:

> On Thu, 2009-06-18 at 10:21 -0600, Jeffrey Barish wrote:
>> GStreamer requires gobject.  gobject runs in a loop, normally by calling
>> the
>> run method on the main loop.  That loop blocks until there is something
>> to
>> do.  I also need to monitor sockets over which I send commands about what
>> GStreamer is supposed to do.  Normally, it runs in a loop that blocks
>> until
>> a command arrives on a socket.  It is not possible to run both of these
>> loops in the same thread using the normal procedure because they both
>> block.  One possibility is to perform the looping manually.  gobject has
>> a
>> method that makes it possible to perform an iteration of the context.  I
>> could check the sockets and then perform an iteration that blocks.  I
>> would
>> repeat those two steps every time a message arrives from gobject.  But
>> there are long periods when no messages arrive, so I could be missing
>> commands that have arrived on a socket while I am waiting for a GStreamer
>> message.  If I make the iteration nonblocking, then the loop will buzz
>> too
>> quickly and the CPU load will go to 100%.  If I put in a sleep, I can get
>> the CPU load under control, but then I will be missing both GStreamer
>> messages and socket commands while sleeping.  If I block on the socket
>> access, I could be tardy in responding to GStreamer messages.  So this
>> approach doesn't work.
>
> You can use GLib's GIOChannel API to register the socket file
> descriptor, and get the GObject mainloop to poll it for you efficiently.
>
> See g_io_channel_unix_new () and g_io_add_watch ()

Normally a good approach.  One detail I omitted was that the sockets can
change, so in this case I don't see how I can use this approach.
--
Jeffrey Barish


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GStreamer in double loop

Arnout Vandecappelle
On Thursday 18 June 2009 21:53:29 Jeffrey Barish wrote:
> > You can use GLib's GIOChannel API to register the socket file
> > descriptor, and get the GObject mainloop to poll it for you efficiently.
> >
> > See g_io_channel_unix_new () and g_io_add_watch ()
>
> Normally a good approach.  One detail I omitted was that the sockets can
> change, so in this case I don't see how I can use this approach.

 When you create a new socket, you can also create a new IO channel and watch
for it, no?

 If you want to change the sockets you are watching, you can remove the IO
watch source and add it again later on.

 Regards,
 Arnout

--
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  D206 D44B 5155 DF98 550D  3F2A 2213 88AA A1C7 C933

------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GStreamer in double loop

Jeffrey Barish
Arnout Vandecappelle wrote:

> On Thursday 18 June 2009 21:53:29 Jeffrey Barish wrote:
>> > You can use GLib's GIOChannel API to register the socket file
>> > descriptor, and get the GObject mainloop to poll it for you
>> > efficiently.
>> >
>> > See g_io_channel_unix_new () and g_io_add_watch ()
>>
>> Normally a good approach.  One detail I omitted was that the sockets can
>> change, so in this case I don't see how I can use this approach.
>
>  When you create a new socket, you can also create a new IO channel and
>  watch
> for it, no?
>
>  If you want to change the sockets you are watching, you can remove the IO
> watch source and add it again later on.

Good question.  I don't create the new socket.  There's a server that tells
me what sockets it's using.  If it changes a socket, I'm listening to the
wrong one with g_io_add_watch, so I never find out that the server changed
it.  Mind you, the code that deals with these sockets is working in its own
thread.  If I can just get GObject to run in its own thread I'm done.

Here's what's baffling me.  This works:

        loop = gobject.MainLoop()
        context = loop.get_context()
        while True:
            context.iteration(False)
            time.sleep(1.0)

This doesn't:

        loop = gobject.MainLoop()
        context = loop.get_context()
        while True:
            context.iteration(True)

The difference is that the second one blocks on the iteration.  What is it
about blocking that is incompatible with running this code in its own
thread?  I found this statement in the documentation for Mainloop.run:

The run() method runs a mainloop until the quit() method is called. If this
is called for the thread of the loop's gobject.MainContext, it will process
events from the loop, otherwise it will simply wait.

I think that run is called from the thread of the loop's MainContext because
I just created the MainLoop on the previous line (imagine that lines 2-4
above are replaced by loop.run(), which should be equivalent).  However, I
am observing that run "simply wait[s]".  Could there be something in this
warning?
--
Jeffrey Barish


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GStreamer in double loop

Arnout Vandecappelle
 [This is actually not about GStreamer anymore, but what the heck.]

On Friday 19 June 2009 00:48:39 Jeffrey Barish wrote:

> Here's what's baffling me.  This works:
>
>         loop = gobject.MainLoop()
>         context = loop.get_context()
>         while True:
>             context.iteration(False)
>             time.sleep(1.0)
>
> This doesn't:
>
>         loop = gobject.MainLoop()
>         context = loop.get_context()
>         while True:
>             context.iteration(True)

 Since you haven't registered any sources for the main loop, it will block
forever.  And unless you created another thread or signal handler somewhere
that calls loop.quit(), there is no way to get out of it.

> The difference is that the second one blocks on the iteration.  What is it
> about blocking that is incompatible with running this code in its own
> thread?

 AFAIK mainloops aren't really meant to be controlled from multiple threads.  
Inside the context.iteration(True), the mainloop will block waiting for an
event on any of its registered sources.  Once it's blocking, I don't think
adding a source from another thread interrupts the block.  You'd probably
need to do a loop.quit() and re-run the mainloop.

 Regards,
 Arnout


--
Arnout Vandecappelle                               arnout at mind be
Senior Embedded Software Architect                 +32-16-286540
Essensium/Mind                                     http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium                BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  D206 D44B 5155 DF98 550D  3F2A 2213 88AA A1C7 C933

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: GStreamer in double loop

Jeffrey Barish
Arnout Vandecappelle wrote:

>  [This is actually not about GStreamer anymore, but what the heck.]
>
> On Friday 19 June 2009 00:48:39 Jeffrey Barish wrote:
>> Here's what's baffling me.  This works:
>>
>>         loop = gobject.MainLoop()
>>         context = loop.get_context()
>>         while True:
>>             context.iteration(False)
>>             time.sleep(1.0)
>>
>> This doesn't:
>>
>>         loop = gobject.MainLoop()
>>         context = loop.get_context()
>>         while True:
>>             context.iteration(True)
>
>  Since you haven't registered any sources for the main loop, it will block
> forever.  And unless you created another thread or signal handler
> somewhere that calls loop.quit(), there is no way to get out of it.
>
>> The difference is that the second one blocks on the iteration.  What is
>> it about blocking that is incompatible with running this code in its own
>> thread?
>
>  AFAIK mainloops aren't really meant to be controlled from multiple
>  threads.
> Inside the context.iteration(True), the mainloop will block waiting for an
> event on any of its registered sources.  Once it's blocking, I don't think
> adding a source from another thread interrupts the block.  You'd probably
> need to do a loop.quit() and re-run the mainloop.

Thanks again for the suggestion.  I did register a source for the main loop,
I just didn't show that code.  Neither of the two versions would work
without a source.  The source is playbin2, which is instantiated in the
main thread (as both loops need to communicate with it).  I serialize
communication with playbin2 from the two threads using a thread-safe queue
(except that for some reason it does not work to set a property on playbin2
(e.g., 'uri') through the queue, so I set that one directly).  Now that the
code is working, I can tell you that the gobject loop is getting messages
from playbin2 even though they are in different threads.

I solved the problem by adding a gobject.threads_init call.  I believe that
this call is required only by the Python bindings for gobject.

The only remaining problem of which I am aware (aside from the strangeness
with setting the uri property) is this error message:

Received message [<GstGError at 0x9ebaf90>, 'gstbin.c(2240):
gst_bin_do_latency_func (): /GstPlayBin2:player:\nFailed to configure
latency of 0:00:00.000000000']

I get this error message at every segue.  Anyone know what it means?
--
Jeffrey Barish


------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

How to syncronize audio and video

zelalem
Hi all, I wanted to save a networked stream in an avi file and I got a very unsynchronized file. The audio finishes almost 3 second ahead of the video. I even used the sync=true option for the filesink element, but the result is the same. So, I want to ask an advice on how to get a synchronized video file. The following is the source and destination commands that I used:

Source commands:

for the audio channel
gst-launch-0.10 -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 ! audioconvert ! alawenc !  rtppcmapay ! queue ! udpsink port=5002
for the video channel;
gst-launch v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate ! video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay ! udpsink port=5000

Output command:
gst-launch-0.10 -v avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc port=5000 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998" num-buffers=5000 ! queue ! rtph263pdepay ! 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} ! mux.video_0 {udpsrc port=5002 caps="application/x-rtp,media=(string)audio,payload=(int)96, rate=(int)8000, encoding-name=(string)PCMA" ! queue ! rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue} ! mux.audio_0;

Do you think the result will be different if I use a different file container (like mp4) instead of avi?

Thank you.

- Zelalem S.






See all the ways you can stay connected to friends and family
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to syncronize audio and video

Thabelo Mmbengeni-2
Try using the "gstrtpbin" it works, checkout the documentation on the gstreamer site.

eg  Your source can be something like

source -> encode -> payload -> gstrtpbin -> rtpsink(udp)


On Mon, Jun 22, 2009 at 9:45 AM, Zelalem Sintayehu <[hidden email]> wrote:
Hi all, I wanted to save a networked stream in an avi file and I got a very unsynchronized file. The audio finishes almost 3 second ahead of the video. I even used the sync=true option for the filesink element, but the result is the same. So, I want to ask an advice on how to get a synchronized video file. The following is the source and destination commands that I used:

Source commands:

for the audio channel
gst-launch-0.10 -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 ! audioconvert ! alawenc !  rtppcmapay ! queue ! udpsink port=5002
for the video channel;
gst-launch v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate ! video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay ! udpsink port=5000

Output command:
gst-launch-0.10 -v avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc port=5000 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998" num-buffers=5000 ! queue ! rtph263pdepay ! 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} ! mux.video_0 {udpsrc port=5002 caps="application/x-rtp,media=(string)audio,payload=(int)96, rate=(int)8000, encoding-name=(string)PCMA" ! queue ! rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue} ! mux.audio_0;

Do you think the result will be different if I use a different file container (like mp4) instead of avi?

Thank you.

- Zelalem S.






See all the ways you can stay connected to friends and family

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to syncronize audio and video

zelalem
Hi Thabelo, thank you for your response. BTW, my problem is not on the source side. It is on the receiver side. You know when i see the file that i saved in it is very unsynchronized. Eventually I want to use my program to save streams that are comming from the network. So, I am only intersting on the recieving side.  Anyway, I will try to use gstrtpbin if it solves the problem. BTW, how can i put the two differnet streams in teh bin?

Thank you again.

- Zelalem S.


Date: Mon, 22 Jun 2009 12:14:41 +0200
From: [hidden email]
To: [hidden email]
Subject: Re: [gst-devel] How to syncronize audio and video

Try using the "gstrtpbin" it works, checkout the documentation on the gstreamer site.

eg  Your source can be something like

source -> encode -> payload -> gstrtpbin -> rtpsink(udp)


On Mon, Jun 22, 2009 at 9:45 AM, Zelalem Sintayehu <[hidden email]> wrote:
Hi all, I wanted to save a networked stream in an avi file and I got a very unsynchronized file. The audio finishes almost 3 second ahead of the video. I even used the sync=true option for the filesink element, but the result is the same. So, I want to ask an advice on how to get a synchronized video file. The following is the source and destination commands that I used:

Source commands:

for the audio channel
gst-launch-0.10 -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 ! audioconvert ! alawenc !  rtppcmapay ! queue ! udpsink port=5002
for the video channel;
gst-launch v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate ! video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay ! udpsink port=5000

Output command:
gst-launch-0.10 -v avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc port=5000 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998" num-buffers=5000 ! queue ! rtph263pdepay ! 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} ! mux.video_0 {udpsrc port=5002 caps="application/x-rtp,media=(string)audio,payload=(int)96, rate=(int)8000, encoding-name=(string)PCMA" ! queue ! rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue} ! mux.audio_0;

Do you think the result will be different if I use a different file container (like mp4) instead of avi?

Thank you.

- Zelalem S.






See all the ways you can stay connected to friends and family

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




What can you do with the new Windows Live? Find out
------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to syncronize audio and video

Thabelo Mmbengeni-2
Here are the sinks and sources of the gstrtpbin, each session has its own id.
Also look at script file attached for example


GObject
 +----GstObject
       +----GstElement
             +----GstBin
                   +----GstRtpBin

Implemented Interfaces:
  GstChildProxy

Pad Templates:
  SINK template: 'recv_rtp_sink_%d'
    Availability: On request
      Has request_new_pad() function: gst_rtp_bin_request_new_pad
    Capabilities:
      application/x-rtp

  SINK template: 'recv_rtcp_sink_%d'
    Availability: On request
      Has request_new_pad() function: gst_rtp_bin_request_new_pad
    Capabilities:
      application/x-rtcp

  SINK template: 'send_rtp_sink_%d'
    Availability: On request
      Has request_new_pad() function: gst_rtp_bin_request_new_pad
    Capabilities:
      application/x-rtp

  SRC template: 'recv_rtp_src_%d_%d_%d'
    Availability: Sometimes
    Capabilities:
      application/x-rtp

  SRC template: 'send_rtcp_src_%d'
    Availability: On request
      Has request_new_pad() function: gst_rtp_bin_request_new_pad
    Capabilities:
      application/x-rtcp

  SRC template: 'send_rtp_src_%d'
    Availability: Sometimes
    Capabilities:
      application/x-rtp




On Mon, Jun 22, 2009 at 2:11 PM, Zelalem Sintayehu <[hidden email]> wrote:
Hi Thabelo, thank you for your response. BTW, my problem is not on the source side. It is on the receiver side. You know when i see the file that i saved in it is very unsynchronized. Eventually I want to use my program to save streams that are comming from the network. So, I am only intersting on the recieving side.  Anyway, I will try to use gstrtpbin if it solves the problem. BTW, how can i put the two differnet streams in teh bin?

Thank you again.

- Zelalem S.


Date: Mon, 22 Jun 2009 12:14:41 +0200
From: [hidden email]
To: [hidden email]
Subject: Re: [gst-devel] How to syncronize audio and video


Try using the "gstrtpbin" it works, checkout the documentation on the gstreamer site.

eg  Your source can be something like

source -> encode -> payload -> gstrtpbin -> rtpsink(udp)


On Mon, Jun 22, 2009 at 9:45 AM, Zelalem Sintayehu <[hidden email]> wrote:
Hi all, I wanted to save a networked stream in an avi file and I got a very unsynchronized file. The audio finishes almost 3 second ahead of the video. I even used the sync=true option for the filesink element, but the result is the same. So, I want to ask an advice on how to get a synchronized video file. The following is the source and destination commands that I used:

Source commands:

for the audio channel
gst-launch-0.10 -v alsasrc ! queue ! audio/x-raw-int,rate=8000,channels=1,depth=8 ! audioconvert ! alawenc !  rtppcmapay ! queue ! udpsink port=5002
for the video channel;
gst-launch v4l2src ! video/x-raw-rgb,width=320,height=240 ! queue ! videorate ! video/x-raw-rgb,rate=15/1 ! ffmpegcolorspace! ffenc_h263p ! rtph263ppay ! udpsink port=5000

Output command:
gst-launch-0.10 -v avimux name=mux ! filesink location=videoandaudio.avi sync=true {udpsrc port=5000 caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998" num-buffers=5000 ! queue ! rtph263pdepay ! 'video/x-h263,width=320,height=240,framerate=(fraction)25/1' ! queue} ! mux.video_0 {udpsrc port=5002 caps="application/x-rtp,media=(string)audio,payload=(int)96, rate=(int)8000, encoding-name=(string)PCMA" ! queue ! rtppcmadepay ! 'audio/x-alaw, rate=(int)8000, channels=(int)1' ! queue} ! mux.audio_0;

Do you think the result will be different if I use a different file container (like mp4) instead of avi?

Thank you.

- Zelalem S.






See all the ways you can stay connected to friends and family

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




What can you do with the new Windows Live? Find out

------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



------------------------------------------------------------------------------
Are you an open source citizen? Join us for the Open Source Bridge conference!
Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250.
Need another reason to go? 24-hour hacker lounge. Register today!
http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel

client-H264-PCMA.sdp (324 bytes) Download Attachment
server-v4l2-H264-alsasrc-PCMA.sh (5K) Download Attachment