Using concat to switch src

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

Using concat to switch src

TheGiamig
Hi all,
I created a "mybin" containing a filesrc + rawaudioparse to read a PCM file.
It works fine.
Another requirement is the play/pause/stop/loop control, just to control my
bin, not the whole pipeline.
To implement the loop function, I catched the EOS event and sended a seek
event to rawaudioparse so the file will correctly restart.
The problem is the running time that restarts too. The rest of pipeline
don't know about the seek because I want just restart one file, so eg. a
mixer after the rawaudioparse stops mixing another connected audio source
because the timestamps.

I'm thinking using concat to switch from two filesrc to implement the loop
(or from a filesrc and a fakesrc to implement a stop), but don't sounds good
to me..

Any cue? I'm stuck on this problem from many days ago :(





--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using concat to switch src

Gst-Geek
Instead of EOS. Try to capture end of segment message. Use seek event
immediately after end of segment.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using concat to switch src

Nicolas Dufresne-5
In reply to this post by TheGiamig
Le mercredi 10 octobre 2018 à 03:40 -0500, TheGiamig a écrit :

> Hi all,
> I created a "mybin" containing a filesrc + rawaudioparse to read a PCM file.
> It works fine.
> Another requirement is the play/pause/stop/loop control, just to control my
> bin, not the whole pipeline.
> To implement the loop function, I catched the EOS event and sended a seek
> event to rawaudioparse so the file will correctly restart.
> The problem is the running time that restarts too. The rest of pipeline
> don't know about the seek because I want just restart one file, so eg. a
> mixer after the rawaudioparse stops mixing another connected audio source
> because the timestamps.
>
> I'm thinking using concat to switch from two filesrc to implement the loop
> (or from a filesrc and a fakesrc to implement a stop), but don't sounds good
> to me..
>
> Any cue? I'm stuck on this problem from many days ago :(
I've used this approach once, though you need to make sure to cleanup
the sources and pads when done. Maybe for this case you want to try and
multifilesrc loop=1 ?

>
>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Using concat to switch src

TheGiamig
ShilVin wrote
> Instead of EOS. Try to capture end of segment message. Use seek event
> immediately after end of segment.

Through a probe on rawaudioparse srcpad?



Nicolas Dufresne-5 wrote
> Maybe for this case you want to try and
> multifilesrc loop=1 ?

Uhmm, the loop is one function required and sure multifilesrc loop=1 can do
the work.
How about play/stop/pause?

Can be something like this?:
Stop: I think I need a fakesrc to put out silence buffers (or empty
buffers?) because a src is needed anyway (again, I think)

Pause: same as Stop but saving the running time?

Play: make a seek a the beginning or the last saved running time ?

After a seek, how to fix the running time (to push out of the bin) in order
to make it always seemless so the rest of pipeline can continue smoothly?

Thanks




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using concat to switch src

TheGiamig
Any ideas about a bin with play/stop/pause/seek functions for PCM audio files
that flows with seamless timestamps?

I'm working on a more complex project but if I'm stuck for these simple
functions I can figure out for the rest..
GStreamer is really powerful but it seems to me that it lacks of detailed
guide and/or books. So to write a complex software is first a matter of
deeply understand the framework, so much that the develop time will increase
very much.

I wonder if GStreamer is the right way to go for my project.





--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using concat to switch src

Antonio Ospite-2
On Tue, 16 Oct 2018 03:24:46 -0500 (CDT)
TheGiamig <[hidden email]> wrote:

> Any ideas about a bin with play/stop/pause/seek functions for PCM audio files
> that flows with seamless timestamps?
>

When you say "seameless timestamps" do you mean that you want to be able
to pause/stop/seek your audio, possibly producing silence, without the
rest of the pipeline noticing?

Let's schematize the options:

a. Normal pause:

Time:   0              4
Sample: ABCD...........EFG
Event:     ^pause     ^play

b. Pause/Silence with time progressing and audio discarded:

Time:   0              15
Sample: ABCD...........PQR
Event:     ^pause     ^play

c. Pause with time progressing but audio "frozen":

Time:   0              15
Sample: ABCD...........EFG
Event:     ^pause     ^play


a. is a normal pause, when you pause the whole pipeline,

b. can be achieved using input-selector and switching between your audio
source and an audiotestsrc which produces silence, see:
https://git.ao2.it/experiments/gstreamer.git/blob/HEAD:/python/gst-input-selector-switch.py

c. could be achieved using two separate pipelines connected by
interaudiosink and interaudiosrc, and you would pause the first pipeline
without affecting the second pipeline, look at:
https://git.ao2.it/experiments/gstreamer.git/blob/HEAD:/python/gst-decoupled-pipelines.py

Maybe c. could also be achieved with input-selector changing the state
of inactive sources with a change like this:

diff --git a/python/gst-input-selector-switch.py b/python/gst-input-selector-switch.py
index 4f622c6..55d0bef 100755
--- a/python/gst-input-selector-switch.py
+++ b/python/gst-input-selector-switch.py
@@ -13,9 +13,9 @@ GObject.threads_init()

 # The following pipeline works
 PIPELINE = """
-videotestsrc pattern=0 ! selector.
-videotestsrc pattern=18 background-color=4294901760 ! selector.
-input-selector name=selector ! autovideosink
+videotestsrc pattern=0 is-live=true ! selector.
+videotestsrc pattern=18 background-color=4294901760 is-live=true ! selector.
+input-selector name=selector sync-streams=false ! autovideosink
 """


@@ -53,7 +53,9 @@ class Player:
         print("switching from %s to %s" % (active_pad.get_name(),
                                            new_pad.get_name()))

+        active_pad.get_peer().get_parent().set_state(Gst.State.PAUSED)
         self.selector.set_property("active-pad", new_pad)
+        new_pad.get_peer().get_parent().set_state(Gst.State.PLAYING)

     def on_eos(self, bus, msg):
         self.quit()


For seeking, using interaudiosink/interaudiosrc is probably the quickest way.

These are just quick and dirty examples of course.

Ciao,
   Antonio

--
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using concat to switch src

TheGiamig
Antonio Ospite-2 wrote
> On Tue, 16 Oct 2018 03:24:46 -0500 (CDT)
> TheGiamig &lt;

> thegiamig@

> &gt; wrote:
>
>> Any ideas about a bin with play/stop/pause/seek functions for PCM audio
>> files
>> that flows with seamless timestamps?
>>
>
> When you say "seameless timestamps" do you mean that you want to be able
> to pause/stop/seek your audio, possibly producing silence, without the
> rest of the pipeline noticing?
>
> Let's schematize the options:
>
> a. Normal pause:
>
> Time:   0              4
> Sample: ABCD...........EFG
> Event:     ^pause     ^play
>
> b. Pause/Silence with time progressing and audio discarded:
>
> Time:   0              15
> Sample: ABCD...........PQR
> Event:     ^pause     ^play
>
> c. Pause with time progressing but audio "frozen":
>
> Time:   0              15
> Sample: ABCD...........EFG
> Event:     ^pause     ^play
>
>
> a. is a normal pause, when you pause the whole pipeline,
>
> b. can be achieved using input-selector and switching between your audio
> source and an audiotestsrc which produces silence, see:
> https://git.ao2.it/experiments/gstreamer.git/blob/HEAD:/python/gst-input-selector-switch.py
>
> c. could be achieved using two separate pipelines connected by
> interaudiosink and interaudiosrc, and you would pause the first pipeline
> without affecting the second pipeline, look at:
> https://git.ao2.it/experiments/gstreamer.git/blob/HEAD:/python/gst-decoupled-pipelines.py
>
> Maybe c. could also be achieved with input-selector changing the state
> of inactive sources with a change like this:
>
> diff --git a/python/gst-input-selector-switch.py
> b/python/gst-input-selector-switch.py
> index 4f622c6..55d0bef 100755
> --- a/python/gst-input-selector-switch.py
> +++ b/python/gst-input-selector-switch.py
> @@ -13,9 +13,9 @@ GObject.threads_init()
>
>  # The following pipeline works
>  PIPELINE = """
> -videotestsrc pattern=0 ! selector.
> -videotestsrc pattern=18 background-color=4294901760 ! selector.
> -input-selector name=selector ! autovideosink
> +videotestsrc pattern=0 is-live=true ! selector.
> +videotestsrc pattern=18 background-color=4294901760 is-live=true !
> selector.
> +input-selector name=selector sync-streams=false ! autovideosink
>  """
>
>
> @@ -53,7 +53,9 @@ class Player:
>          print("switching from %s to %s" % (active_pad.get_name(),
>                                             new_pad.get_name()))
>
> +        active_pad.get_peer().get_parent().set_state(Gst.State.PAUSED)
>          self.selector.set_property("active-pad", new_pad)
> +        new_pad.get_peer().get_parent().set_state(Gst.State.PLAYING)
>
>      def on_eos(self, bus, msg):
>          self.quit()
>
>
> For seeking, using interaudiosink/interaudiosrc is probably the quickest
> way.
>
> These are just quick and dirty examples of course.
>
> Ciao,
>    Antonio
>
> --
> Antonio Ospite
> https://ao2.it
> https://twitter.com/ao2it
>
> A: Because it messes up the order in which people normally read text.
>    See http://en.wikipedia.org/wiki/Posting_style
> Q: Why is top-posting such a bad thing?
> _______________________________________________
> gstreamer-devel mailing list

> gstreamer-devel@.freedesktop

> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


Hi Antonio, you got it.
C is my case,  but a second pipeline sounds to me a little overkill (but
working :) ).
I will think about your solution, but my idea was to insert a custom element
between the PCM source (filesrc/multifilesrc/fakesrc) and the parser
(audioparse) so I can intercept any data and events.
I think the "seamless timestamps" can be achieved just modifying some events
content and/or buffer PTS. In pause/stop the source have to be a silence
generator like fakesrc or audiotestsrc, so input-selector can help the
switch.
In this case the state play/pause/stop will be an internal logical state,
not directly linked to the elements state (the pipeline will be always in
playing state).
I think the fist step can be to understand which events and how to modify
them so timestamps never jump (as per concat element?).

Thanks








--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Using concat to switch src

TheGiamig
Hi all, I'm yet puzzled about my "seameless timestamps" problem.
Actually I better understand how to create an element able to send seek to
upstream and mask it to downstream elements. So I can loop just a pipeline
section leaving the rest flow normally.
I got some code and pointers from concat element and from gnonlin.
Looping is not my primary goal, so my work proceed.

Now right to the question:
I see a strange behaviour after a seek, I got an audio file 10 seconds long
and, from "my element", I push a seek from 0 to 5 secs to upstream (filesrc
+ audioparse). My element prints the timestamp of incoming buffers. As
expected I see printed all buffers timestamps but the incoming flow don't
stops at 5 seconds but continue  up to 10 seconds. The seek is working
because the segment event is correct and actually the audio from 5 to 10
secs will not be played from alsasink, I guess because outside the segment.
Why audioparse pushes downstream those buffers out of segment?

I run on Raspberry Pi with GStreamer 1.4.4 and I wonder if a so old version
can be a problem.
I would like update gstreamer to last version but seems to me that I have to
download and compile it because there is not official packets available.
Actually I ave no time to spend for that.

Thanks




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel