v 1.12, Incorrect current position of GstPipeline is reported
Mathieu Duponchelle
mathieu at centricular.com
Tue Mar 27 00:35:38 UTC 2018
Also, more importantly, do you have any reason for not using GESPipeline?
If not, I advise you do so, as it's the recommended way to run a GES timeline.
On 03/27/2018 02:20 AM, David Ing wrote:
> I have a gstreamer pipeline which basically incorporates a GESTimeline, two encoders (audio and video), a muxer, and a filesink.
>
> When I run the pipeline, I periodically query the stream position (as shown in code below) and print into the terminal (stdout).
>
> The problem is: When I run the pipeline, the terminal says that I have reached 100% relatively early (within 2 seconds), but the pipeline itself continues to run for 10 more seconds. When the terminal reports being 100% done, I can see that the target mp4 file (the final output of the pipeline) is less than 5% of it's final size.
>
> My goal is to get an accurate indication of the job's progress as it runs
>
> Other things I've tried.
>
> * Tried listening for GST_MESSAGE_PROGRESS messages, but I don't get any.
> * Tried executing `gst_element_query_position` on the filesink (the last element of the pipeline), instead of the entire pipeline itself, but my results did not change.
>
> The code for my main loop is shown below. The progress printing occurs near the very bottom of the loop.
>
> /// Run the job. Will throw exception if unsuccessful.
> void CompositionJob::run()
> {
> GstStateChangeReturn stateChangeReturn;
>
> // Start playing the pipeline.
> stateChangeReturn = gst_element_set_state(reinterpret_cast<GstElement*>(this->gstPipeline), GST_STATE_PLAYING);
> if (stateChangeReturn == GST_STATE_CHANGE_FAILURE)
> throw std::runtime_error("Unable to set the pipeline to the playing state.");
>
> // Talk to the message bus
> this->gstBus = gst_element_get_bus(reinterpret_cast<GstElement*>(this->gstPipeline));
> unique_gmob<GstMessage> gstMessage = nullptr;
>
> this->shouldTerminate = false;
> while (!this->shouldTerminate)
> {
> gstMessage = gst_bus_timed_pop_filtered(this->gstBus, 100 * GST_MSECOND,
> (GstMessageType)(GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS | GST_MESSAGE_DURATION));
>
> if (gstMessage)
> {
> this->handleMessage(gstMessage.get());
> gstMessage.reset();
> }
> else
> {
> // If we got no message, a timeout period has expired.
> if (this->isPlaying)
> {
> // Query the stream position (in nanoseconds).
> if (!gst_element_query_position(
> reinterpret_cast<GstElement*>(this->gstPipeline),
> GST_FORMAT_TIME,
> &this->streamPosition))
> GST_DEBUG("Could not query current position.");
>
> // Query the duration if we don't have it already.
> if (!GST_CLOCK_TIME_IS_VALID(this->streamDuration))
> {
> if (!gst_element_query_duration(
> reinterpret_cast<GstElement*>(this->gstPipeline),
> GST_FORMAT_TIME,
> &this->streamDuration))
> GST_DEBUG("Could not get pipeline duration.");
> }
>
> // Print position and duration.
> if (this->printProgress)
> {
> g_print("Position %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\r",
> GST_TIME_ARGS(this->streamPosition), GST_TIME_ARGS(this->streamDuration));
> }
> }
> }
> }
> }
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20180327/ff6c4765/attachment.html>
More information about the gstreamer-devel
mailing list