Changing file location during recording

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

Changing file location during recording

Albert Costa
Hi,
I have a pipeline that can be reducted to:

gst-launch dshowvideosrc ! tee ! queue ! ffmpegcolorspace ! ffenc_mpeg2video ! mpegtsmux ! filesink tee0. ! queue ! ffmpegcolorspace ! directdrawsink

All this is created/handled in a c application where I can start and stop the pipeline. I now have a requirement to change the location of the file after a given size (for example) is reached. I've started to test following sequence on user request for the moment:
-set pipeline to paused
-change filesink location
-set back pipeline to playing
But it seems it does not handle the change of location in the filesink. I've also tried to unlink/relink the filesink branch in combination with the state change, with no success.
Is there a way to change dynamically the filesink location, either by external commands (like I tried) or even better automatically with a plugin I am maybe not aware of?
Thanks for help,
Regards,
Al


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing file location during recording

Sudarshan Bisht
I don't know that how you are doing it but I think better way of doing it is pause the pipeline and check in the bus callback that pipeline is really paused then only change the location of the file . Then set the pipeline state to play.
 


 
On Wed, Jun 16, 2010 at 9:57 PM, Albert Costa <[hidden email]> wrote:
Hi,
I have a pipeline that can be reducted to:

gst-launch dshowvideosrc ! tee ! queue ! ffmpegcolorspace ! ffenc_mpeg2video ! mpegtsmux ! filesink tee0. ! queue ! ffmpegcolorspace ! directdrawsink

All this is created/handled in a c application where I can start and stop the pipeline. I now have a requirement to change the location of the file after a given size (for example) is reached. I've started to test following sequence on user request for the moment:
-set pipeline to paused
-change filesink location
-set back pipeline to playing
But it seems it does not handle the change of location in the filesink. I've also tried to unlink/relink the filesink branch in combination with the state change, with no success.
Is there a way to change dynamically the filesink location, either by external commands (like I tried) or even better automatically with a plugin I am maybe not aware of?
Thanks for help,
Regards,
Al


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel




--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing file location during recording

Aurelien Grimaud (elzz)
In reply to this post by Albert Costa
Hi,
I think that file is opened during the NULL -> READY transition and you cannot change a filesink location when file is already opened.
therefore, your filesink has to go to NULL in order to close the initial file and then to playing again to open the new file.

Block the tee sink pad before setting to NULL if you do not want to lose data.

Aurelien


Le 16/06/2010 18:27, Albert Costa a écrit :
Hi,
I have a pipeline that can be reducted to:

gst-launch dshowvideosrc ! tee ! queue ! ffmpegcolorspace ! ffenc_mpeg2video ! mpegtsmux ! filesink tee0. ! queue ! ffmpegcolorspace ! directdrawsink

All this is created/handled in a c application where I can start and stop the pipeline. I now have a requirement to change the location of the file after a given size (for example) is reached. I've started to test following sequence on user request for the moment:
-set pipeline to paused
-change filesink location
-set back pipeline to playing
But it seems it does not handle the change of location in the filesink. I've also tried to unlink/relink the filesink branch in combination with the state change, with no success.
Is there a way to change dynamically the filesink location, either by external commands (like I tried) or even better automatically with a plugin I am maybe not aware of?
Thanks for help,
Regards,
Al

------------------------------------------------------------------------------ ThinkGeek and WIRED's GeekDad team up for the Ultimate GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the lucky parental unit. See the prize list and enter to win: http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Changing file location during recording

Edward Hervey
In reply to this post by Albert Costa
On Wed, 2010-06-16 at 16:27 +0000, Albert Costa wrote:

> Hi,
> I have a pipeline that can be reducted to:
>
>
> gst-launch dshowvideosrc ! tee ! queue ! ffmpegcolorspace !
> ffenc_mpeg2video ! mpegtsmux ! filesink tee0. ! queue !
> ffmpegcolorspace ! directdrawsink
>
>
> All this is created/handled in a c application where I can start and
> stop the pipeline. I now have a requirement to change the location of
> the file after a given size (for example) is reached. I've started to
> test following sequence on user request for the moment:
> -set pipeline to paused
> -change filesink location
> -set back pipeline to playing
> But it seems it does not handle the change of location in the
> filesink. I've also tried to unlink/relink the filesink branch in
> combination with the state change, with no success.
> Is there a way to change dynamically the filesink location, either by
> external commands (like I tried) or even better automatically with a
> plugin I am maybe not aware of?

 You want to, when no data is flowing : set the filesink to the NULL
state, change the location, bring back the filesink to the PLAYING
state. To ensure no data is flowing, use the gst_pad_set_blocked_async()
method on the pad feeding data to your filesink.

 * Grab the mpegtsmux source pad and
gst_pad_set_blocked_async(sourcepad, TRUE, my_blocked_callback,
filesink);
 * In your my_blocked_callback:
 ** WHEN blocked is TRUE:
 *** set filesink to NULL,
 *** change the location property of filesink,
 *** set filesink to PLAYING,
 *** and finally call gst_pad_set_blocked_async(sourcepad, FALSE,
my_blocked_callback, NULL);

  Edward

P.S. You can only do this with container formats that don't have headers
(like mpeg-ts). There might also be quirks about the PMT/PAT not being
present at the beginning of the second file.


> Thanks for help,
> Regards,
> Al
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re : Changing file location during recording

Albert Costa
Hi,
thanks a lot to all people, this works fine! 
Now my only concern left is to be able to reset the timestamps (start again at 0) when changing the file. Currently when I apply this solution, timestamps continue to increase (for example 0 to 2 seconds in first file, then 2 to 4 seconds in the second file when I change it). 
I've tried to put a homemade plugin that offsets the timestamps back to 0 when I change the file (changing my branch to tee0. ! queue ! offsetplugin ! ffenc ! mpgtsmux ! filesink). But it seems it doen't work well: even doing that, dumping the timestamps of the second file starts at 2 seconds (with this example).
Regards,
Al


De : Edward Hervey <[hidden email]>
À : Discussion of the development of GStreamer <[hidden email]>
Envoyé le : Jeu 17 juin 2010, 8h 36min 15s
Objet : Re: [gst-devel] Changing file location during recording

On Wed, 2010-06-16 at 16:27 +0000, Albert Costa wrote:

> Hi,
> I have a pipeline that can be reducted to:
>
>
> gst-launch dshowvideosrc ! tee ! queue ! ffmpegcolorspace !
> ffenc_mpeg2video ! mpegtsmux ! filesink tee0. ! queue !
> ffmpegcolorspace ! directdrawsink
>
>
> All this is created/handled in a c application where I can start and
> stop the pipeline. I now have a requirement to change the location of
> the file after a given size (for example) is reached. I've started to
> test following sequence on user request for the moment:
> -set pipeline to paused
> -change filesink location
> -set back pipeline to playing
> But it seems it does not handle the change of location in the
> filesink. I've also tried to unlink/relink the filesink branch in
> combination with the state change, with no success.
> Is there a way to change dynamically the filesink location, either by
> external commands (like I tried) or even better automatically with a
> plugin I am maybe not aware of?

You want to, when no data is flowing : set the filesink to the NULL
state, change the location, bring back the filesink to the PLAYING
state. To ensure no data is flowing, use the gst_pad_set_blocked_async()
method on the pad feeding data to your filesink.

* Grab the mpegtsmux source pad and
gst_pad_set_blocked_async(sourcepad, TRUE, my_blocked_callback,
filesink);
* In your my_blocked_callback:
** WHEN blocked is TRUE:
*** set filesink to NULL,
*** change the location property of filesink,
*** set filesink to PLAYING,
*** and finally call gst_pad_set_blocked_async(sourcepad, FALSE,
my_blocked_callback, NULL);

  Edward

P.S. You can only do this with container formats that don't have headers
(like mpeg-ts). There might also be quirks about the PMT/PAT not being
present at the beginning of the second file.


> Thanks for help,
> Regards,
> Al
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re : Changing file location during recording

Marco Ballesio
Hi,

On Thu, Jun 17, 2010 at 3:16 PM, Albert Costa <[hidden email]> wrote:

> Hi,
> thanks a lot to all people, this works fine!
> Now my only concern left is to be able to reset the timestamps (start again
> at 0) when changing the file. Currently when I apply this solution,
> timestamps continue to increase (for example 0 to 2 seconds in first file,
> then 2 to 4 seconds in the second file when I change it).
> I've tried to put a homemade plugin that offsets the timestamps back to 0
> when I change the file (changing my branch to tee0. ! queue ! offsetplugin !
> ffenc ! mpgtsmux ! filesink). But it seems it doen't work well: even doing
> that, dumping the timestamps of the second file starts at 2 seconds (with
> this example).

Sorry, for the late reply, hope this helps..

I think here you'd need to put also your source element to NULL and
then back to PLAYING state.

Regards

> Regards,
> Al
> ________________________________
> De : Edward Hervey <[hidden email]>
> À : Discussion of the development of GStreamer
> <[hidden email]>
> Envoyé le : Jeu 17 juin 2010, 8h 36min 15s
> Objet : Re: [gst-devel] Changing file location during recording
>
> On Wed, 2010-06-16 at 16:27 +0000, Albert Costa wrote:
>> Hi,
>> I have a pipeline that can be reducted to:
>>
>>
>> gst-launch dshowvideosrc ! tee ! queue ! ffmpegcolorspace !
>> ffenc_mpeg2video ! mpegtsmux ! filesink tee0. ! queue !
>> ffmpegcolorspace ! directdrawsink
>>
>>
>> All this is created/handled in a c application where I can start and
>> stop the pipeline. I now have a requirement to change the location of
>> the file after a given size (for example) is reached. I've started to
>> test following sequence on user request for the moment:
>> -set pipeline to paused
>> -change filesink location
>> -set back pipeline to playing
>> But it seems it does not handle the change of location in the
>> filesink. I've also tried to unlink/relink the filesink branch in
>> combination with the state change, with no success.
>> Is there a way to change dynamically the filesink location, either by
>> external commands (like I tried) or even better automatically with a
>> plugin I am maybe not aware of?
>
> You want to, when no data is flowing : set the filesink to the NULL
> state, change the location, bring back the filesink to the PLAYING
> state. To ensure no data is flowing, use the gst_pad_set_blocked_async()
> method on the pad feeding data to your filesink.
>
> * Grab the mpegtsmux source pad and
> gst_pad_set_blocked_async(sourcepad, TRUE, my_blocked_callback,
> filesink);
> * In your my_blocked_callback:
> ** WHEN blocked is TRUE:
> *** set filesink to NULL,
> *** change the location property of filesink,
> *** set filesink to PLAYING,
> *** and finally call gst_pad_set_blocked_async(sourcepad, FALSE,
> my_blocked_callback, NULL);
>
>   Edward
>
> P.S. You can only do this with container formats that don't have headers
> (like mpeg-ts). There might also be quirks about the PMT/PAT not being
> present at the beginning of the second file.
>
>
>> Thanks for help,
>> Regards,
>> Al
>>
>>
>>
>> ------------------------------------------------------------------------------
>> ThinkGeek and WIRED's GeekDad team up for the Ultimate
>> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
>> lucky parental unit.  See the prize list and enter to win:
>> http://p.sf.net/sfu/thinkgeek-promo
>> _______________________________________________ gstreamer-devel mailing
>> list [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>

------------------------------------------------------------------------------
This SF.net email is sponsored by Sprint
What will you do first with EVO, the first 4G phone?
Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Re : Changing file location during recording

Wes Miller
Marco,

Don't know if this will help, but filesink also has a property called "ts-offset", timestamp offset in nanoseconds.  It SOUNDS like it ought to adjust timestamps, but the gst-inspect results are not clear.  WHile you have the filesink  idle to change the location, ou could adjust this also.

Wes