multiple input files with input selector

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

multiple input files with input selector

userAr
Hi,

I read about the input-selector and I guess it what my application needs:

I have n audio files, they should be played in a roll (file_1, file_2, file_3,... file_n) without any noticeable delay.

the pipeline is- filesrc location=file_1.mp3 ! decodebin ! audioconvert ! autoaudiosink

at the beginning, the bus got the EOS and the action was:

gst_element_set_state(pipeline, GST_STATE_READY);
g_object_set(G_OBJECT(fileSrc), "location", "file_2.mp3", NULL);
gst_element_set_state(pipeline, GST_STATE_PLAYING);
g_main_loop_run(loop);

which worked, but with delay of ~0.3 sec and its not good enough .

so I though of using the input-selector,  but I understand from  this pot:

http://gstreamer-devel.966125.n4.nabble.com/Using-input-selector-td4664707.html

 that "the switch is not simultaneous—even though I'm switching the audio selector first, the audio switch is late by half a second"

so my question is, if there is some method to switch between inputs (#n fileSrc) to one output- the rest of the pipeline, with unnoticeable delay.

Ill be happy for an example, if there is a code example it will be great

thanks.
Reply | Threaded
Open this post in threaded view
|

Re: multiple input files with input selector

Sebastian Dröge-3
On Tue, 2016-11-08 at 02:15 -0800, userAr wrote:

> Hi, 
>
> I read about the input-selector and I guess it what my application needs:
>
> I have n audio files, they should be played in a roll (file_1, file_2,
> file_3,... file_n) without any noticeable delay.
>
> the pipeline is- filesrc location=file_1.mp3 ! decodebin ! audioconvert !
> autoaudiosink
>
> at the beginning, the bus got the EOS and the action was: 
>
> gst_element_set_state(pipeline, GST_STATE_READY);
> g_object_set(G_OBJECT(fileSrc), "location", "file_2.mp3", NULL);
> gst_element_set_state(pipeline, GST_STATE_PLAYING);
> g_main_loop_run(loop);
>
> which worked, but with delay of ~0.3 sec and its not good enough .
>
> so I though of using the input-selector,  but I understand from  this pot:
>
> http://gstreamer-devel.966125.n4.nabble.com/Using-input-selector-td4664707.html
>
>  that "the switch is not simultaneous—even though I'm switching the audio
> selector first, the audio switch is late by half a second"
>
> so my question is, if there is some method to switch between inputs (#n
> fileSrc) to one output- the rest of the pipeline, with unnoticeable delay.
You would have to reduce buffering everywhere for that, or do the
switching at the soundserver or driver level.

Each audiosink has a buffer, and if you put the input-selector after
the decoder then that will be where the delay comes from in your
pipeline.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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

Re: multiple input files with input selector

userAr
so you are saying to connect the input-selector between the filesrc to decodebin:


                    |-----------------------|
filesrc_1 ------|                            |
                    |                            |
filesrc_2 ------|                            |
.                   |     input-selector    |
.                   |                            |---- decoder --- sink
.                   |                            |
.                   |                            |
filesrc_n ------|                            |
                    |-----------------------|

this should reduce the delay?
so when I get EOS from filesrc_1, I switch to filesrc_2 (which in some state of ready?)
it will automatically pass the stream from filesrc_2 to input-selector on switching command?

do you know where can I find code example for the creating pads and switching?

thank you very much :)
Reply | Threaded
Open this post in threaded view
|

Re: multiple input files with input selector

Sebastian Dröge-3
On Tue, 2016-11-08 at 05:45 -0800, userAr wrote:

> so you are saying to connect the input-selector between the filesrc
> to
> decodebin:
>
>
>                     |-----------------------|
> filesrc_1 ------|                            |
>                     |                            |
> filesrc_2 ------|                            |
> .                   |     input-selector    |
> .                   |                            |---- decoder ---
> sink
> .                   |                            |
> .                   |                            |
> filesrc_n ------|                            |
>                     |-----------------------|
>
> this should reduce the delay?
No, you have to put it *after* the decoder. Then you only have the
buffering inside the sink left.

> so when I get EOS from filesrc_1, I switch to filesrc_2 (which in some state
> of ready?) 
> it will automatically pass the stream from filesrc_2 to input-selector on
> switching command?

Your goal is to switch on EOS? Then use the concat element, it does
exactly that. Put it *after* the decoder and before the sink.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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

Re: multiple input files with input selector

userAr
o.k

thank you :)
Reply | Threaded
Open this post in threaded view
|

Re: multiple input files with input selector

userAr
This post was updated on .
Hi,


just couple of minutes before I give up on the input-selector,

I would like to ask more question.

so the pipeline is configured as described (with the buffers).

when I set the state of the pipeline to playing, I hear the song- the first file.

the switching part (inside the bus implementation):

case GST_MESSAGE_EOS:
                g_print("got End of stream\n");

                g_object_set(G_OBJECT(selector), "active-pad", selectorSinkPad2, NULL);
                g_object_get(G_OBJECT(selector), "active-pad", &oldPad, NULL);
                gst_object_unref(oldPad);
                break;

1. I checked that the "selectorSinkPad2" is not null.
2. I checked that the selector has two sink pads with the "n-pads" property

and yet, I don't hear the second file playing..

maybe the second filesrs was already in "playing" state and when I switched to it, it was too late? is there a need to "wake up" the second filesrc with "ready" state and on the switching part change the state of the second filesrc to "playing"?


BTW, I couldn't find any examples of the concate element...


I  will be happy for guidance :)

thanks

Reply | Threaded
Open this post in threaded view
|

Re: multiple input files with input selector

Sebastian Dröge-3
On Wed, 2016-11-09 at 05:25 -0800, userAr wrote:
>
> [...]
> and yet, I don't hear the second file playing..
>
> maybe the second filesrs was already in "playing" state and when I switched
> to it, it was too late? is there a need to "wake up" the second filesrc with
> "ready" state and on the switching part change the state of the second
> filesrc to "playing"?

The second file will play at the same speed at the same time as the
first, so it won't be at the beginning anymore. Even more important, it
will also go EOS.

For switching from one file to another as a way to have gapless
playback of the second after the first has ended, input-selector is the
wrong element.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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

Re: multiple input files with input selector

userAr
This post was updated on .
thank you for your help.

Is there some code examples for the concat element? I couldn't find any and i'm not sure how to use it.


thanks.
Reply | Threaded
Open this post in threaded view
|

Re: multiple input files with input selector

Sebastian Dröge-3
On Wed, 2016-11-09 at 23:45 -0800, userAr wrote:
> thank you for your help.
>
> Is there some code examples for the concate element? I couldn't find
> any and i'm not sure how to use it.

You connect all inputs you want to concat, and it will pass them
through in the order of the pads. It will switch to the next once the
previous got EOS.

There is an example at the top of the documentation:
https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-plugins/html/gstreamer-plugins-concat.html

> also the gst-inspect-1.0 says- No such element or plugin (im using
> windows)

You need 1.8 or newer.

--
Sebastian Dröge, Centricular Ltd · http://www.centricular.com
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

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

Re: multiple input files with input selector

Saurav
Hello Sebastian,

I checked the below link for example, but it is command line.

gst-launch-1.0 concat name=c ! xvimagesink  videotestsrc num-buffers=100 !
c.   videotestsrc num-buffers=100 pattern=ball ! c.

1. Can you please share its C-Code?
2. I tried to use concat element, By adding it after the File Source
Element.and Connect  Concat Source PAd with the Demux Decodebin. But In this
way, Sometime it stuck on the last frame of the First video and some time
Audio is keep on dropped. How to fix it?

3. I also Tried it after the decoder. e.g 3 Source files are decoded and
then Raw-Data is linked with "Concat" Sink and its source is linked with
video sink and audio sink. (there are two concat element this time. one for
audio and another for video).
In this way video playback happen but it takes 1~2 min to play the second
video.

I don't know i am doing right or not as there is no way to verify with the
sample code of "Concat" element.

Can you please provide guidance with which element to link "Concat" Element
if there are 3 video files?

It will be better if you can share a sample C-Code for this.

Thanks




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