Detect damaged file

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

Detect damaged file

Mikl
Hello,

My question in general is:
How i can detect what file is damaged?

And a problem i have now is:
I have mkv container, not properly closed.
File size is ok, but pipeline was closed before eos event and.
I can not wait on a bus for GST_MESSAGE_ASYNC_DONE.
It is hanging after start prerool.

Thank you.
Mikl
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Mikl
I was trying to make timeout using GstClock, but no luck

        GstClock* clock = gst_pipeline_get_pipeline_clock((GstPipeline*)_pipeline);
        GstClockTime time = 10000000000; //10 sec
        GstClockID timeoutClock = gst_clock_new_single_shot_id(clock, time);

        GstClockReturn t = gst_clock_id_wait_async(timeoutClock, LoopTimeout, this, nullptr);

//wait for normal prerool and stop timer
        gst_clock_id_unschedule(timeoutClock);


and my timeout function is
gboolean LoopTimeout (GstClock *clock, GstClockTime, GstClockID id, gpointer user_data)
{
        g_main_loop_quit(_loop);

        //inform about timeout
}

}

//
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Krutskikh Ivan
Hi.

Was facing the same problem with my server software. Now I'm just using ffprobe/ffmpeg prior to gstreamer.

Cheers!

2016-11-08 11:46 GMT+03:00 Mikl <[hidden email]>:
I was trying to make timeout using GstClock, but no luck

        GstClock* clock = gst_pipeline_get_pipeline_clock((GstPipeline*)_pipeline);
        GstClockTime time = 10000000000; //10 sec
        GstClockID timeoutClock = gst_clock_new_single_shot_id(clock, time);

        GstClockReturn t = gst_clock_id_wait_async(timeoutClock, LoopTimeout, this,
nullptr);

//wait for normal prerool and stop timer
        gst_clock_id_unschedule(timeoutClock);


and my timeout function is
gboolean LoopTimeout (GstClock *clock, GstClockTime, GstClockID id, gpointer
user_data)
{
        g_main_loop_quit(_loop);

        //inform about timeout
}

}

//



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Detect-damaged-file-tp4680534p4680535.html
Sent from the GStreamer-devel mailing list archive at 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
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Mikl
Hello, Ivan

Thank you for reply.

Can you give more details, please?
Example maybe?

Mikl
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Sebastian Dröge-3
In reply to this post by Mikl
On Tue, 2016-11-08 at 00:42 -0800, Mikl wrote:

> Hello,
>
> My question in general is:
> How i can detect what file is damaged?
>
> And a problem i have now is:
> I have mkv container, not properly closed.
> File size is ok, but pipeline was closed before eos event and.
> I can not wait on a bus for GST_MESSAGE_ASYNC_DONE.
> It is hanging after start prerool.
Please make the file available and file a bug. It should never hang,
and instead either properly error out or just work.

--
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: Detect damaged file

Mikl
Hello, Sebastian

Sorry for using word "hanging" without proper explanation.
I am starting pipeline, runing loop and waiting for GST_MESSAGE_ASYNC_DONE on a bus.
Because file is damaged, i never have it, and my app is stuck in this loop.

I need to find a way:
-detect what file is "good" without loop
-or make timeout and shutdown loop after X milliseconds with error

Say me if you need my code.

GStreamer is almost perfect. It is always right. I am happy sins start working in it. Thank you for the perfect tool.
You always can find something to improve. And i already have a list. :)

Mikl
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Krutskikh Ivan
In reply to this post by Mikl
Ok. I was developing a video storage and distribution server in python based on gstreamer and opencv. Server stores video in a sequence on files so I made a little lib over ffprobe and subprocess in python.

I use ffprobe with json output to find out if my cams are alive and their streams are sane and the same with resulting files. It's pretty trivial, but mind that some versions of ffprobe/ffmpeg do not have a timeout and can hang forever when dealing with particullary broken network streams. I'll link the code below.

http://pastebin.com/q29uYBXQ



2016-11-08 15:32 GMT+03:00 Mikl <[hidden email]>:
Hello, Ivan

Thank you for reply.

Can you give more details, please?
Example maybe?

Mikl



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Detect-damaged-file-tp4680534p4680543.html
Sent from the GStreamer-devel mailing list archive at 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
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Sebastian Dröge-3
In reply to this post by Mikl
On Tue, 2016-11-08 at 05:46 -0800, Mikl wrote:

> Hello, Sebastian 
>
> Sorry for using word "hanging" without proper explanation.
> I am starting pipeline, runing loop and waiting for
> GST_MESSAGE_ASYNC_DONE
> on a bus.
> Because file is damaged, i never have it, and my app is stuck in this
> loop.
>
> I need to find a way:
> -detect what file is "good" without loop
> -or make timeout and shutdown loop after X milliseconds with error
>
> Say me if you need my code.
You should either get the pipeline move to PAUSED/PLAYING, or an error
message, or gst_element_set_state() already returns an error.

If you check for all these 3 cases, your code should never hang and if
it does that is a bug in some GStreamer element.

> GStreamer is almost perfect. It is always right. I am happy sins
> start working in it. Thank you for the perfect tool.
> You always can find something to improve. And i already have a list.
> :)

Put that list in Bugzilla, one item at a time, so we can make that
happen :)

--
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: Detect damaged file

Mikl
In reply to this post by Krutskikh Ivan
Hello, Ivan

Thank you for detailed explanation and example.

So, there is no "ring to rule them all". I need to inspect file BEFORE open it in GStareamer. :(

But i am afraid, i can not use ffmpeg in a commercial product because of legal reasons
https://www.ffmpeg.org/legal.html
See last paragraph.

Mikl
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Mikl
In reply to this post by Krutskikh Ivan
Hello, Ivan

Thank you for detailed explanation and example.

So, there is no "ring to rule them all". I need to inspect file BEFORE open it in GStareamer. :(

But i am afraid, i can not use ffmpeg in a commercial product because of legal reasons
https://www.ffmpeg.org/legal.html
See last paragraph.

Mikl
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Mikl
In reply to this post by Sebastian Dröge-3
Hello, Sebastian

This what i have

1. start pipeline
gst_element_set_state(_pipeline, GST_STATE_PAUSED);

2. start loop
g_main_loop_run(_loop);

3. listen for messages
BusCallback(GstBus* bus, GstMessage* message, void* data)

4. closing loop after done or error
case GST_MESSAGE_ASYNC_DONE:
case GST_MESSAGE_EOS:
    g_main_loop_quit(_loop);

And i don`t have any of them, if recording pipeline was closed before EOS
And my app id hanging.

Mikl
Reply | Threaded
Open this post in threaded view
|

Re: Detect damaged file

Sebastian Dröge-3
On Wed, 2016-11-09 at 01:10 -0800, Mikl wrote:

> Hello, Sebastian
>
> This what i have
>
> 1. start pipeline
> gst_element_set_state(_pipeline, GST_STATE_PAUSED);
>
> 2. start loop
> g_main_loop_run(_loop);
>
> 3. listen for messages
> BusCallback(GstBus* bus, GstMessage* message, void* data)
>
> 4. closing loop after done or error
> case GST_MESSAGE_ASYNC_DONE:
> case GST_MESSAGE_EOS:
>     g_main_loop_quit(_loop);
>
> And i don`t have any of them, if recording pipeline was closed before
> EOS And my app id hanging.
So you don't get ASYNC_DONE, EOS or ERROR and gst_element_set_state()
also did not return FAILURE?

Please file a bug with your file in question and a testcase to
reproduce the problem then.

--
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: Detect damaged file

Mikl

Hello, Sebastian 


I am happy to say, what it is not a bug. 😊

As always I used to say my teacher: it is always your fault.


I was constantly attaching call back function:

_bus = gst_pipeline_get_bus(GST_PIPELINE(_pipeline));
gst_bus_add_watch(_bus, BusCallback, this);

without unref and remove watch:

gst_bus_remove_watch(_bus);
gst_object_unref(_bus);

And sooner or later GStreamer cannot manage such this amount of call backs anymore. It is logical.

Thank you for GStreamer and sorry for bad programming.

Mikl




From: Sebastian Dröge-3 [via GStreamer-devel] <ml-node+[hidden email]>
Sent: Wednesday, November 9, 2016 10:33:28 AM
To: Michael Yarochkin
Subject: Re: Detect damaged file
 
On Wed, 2016-11-09 at 01:10 -0800, Mikl wrote:

> Hello, Sebastian
>
> This what i have
>
> 1. start pipeline
> gst_element_set_state(_pipeline, GST_STATE_PAUSED);
>
> 2. start loop
> g_main_loop_run(_loop);
>
> 3. listen for messages
> BusCallback(GstBus* bus, GstMessage* message, void* data)
>
> 4. closing loop after done or error
> case GST_MESSAGE_ASYNC_DONE:
> case GST_MESSAGE_EOS:
>     g_main_loop_quit(_loop);
>
> And i don`t have any of them, if recording pipeline was closed before
> EOS And my app id hanging.
So you don't get ASYNC_DONE, EOS or ERROR and gst_element_set_state()
also did not return FAILURE?

Please file a bug with your file in question and a testcase to
reproduce the problem then.

--
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



If you reply to this email, your message will be added to the discussion below:
http://gstreamer-devel.966125.n4.nabble.com/Detect-damaged-file-tp4680534p4680573.html
To unsubscribe from Detect damaged file, click here.
NAML