New segment and mp4mux

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

New segment and mp4mux

Grégoire Gentil
I'm using this test case

https://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/tests/icles/test-segment-seeks.c

and I have simply replaced the pipeline by:

filesrc location=%s ! qtdemux name=demux ! queue ! h264parse ! queue !
mpegpsmux name=mux ! filesink location=/tmp/a.mp4

This works OK. Here is the full file:

https://pastebin.com/Ue2HRReX



But if I replace mpegpsmux by mp4mux (everything else unchanged), the
resulting video is broken. This unfortunately makes sense because the
timestamps of the video are not correct anymore and mp4mux care about this.

What kind of event am I supposed to send downstream to make happy
mp4mux? I have tried many things including sending new segment events,
changing the buffer_dts timestamp in a pad sink callback. Nothing works.

I have read the code of splitmuxsink which faces a similar situation but
it's also slightly different because the plugin resets when each new
file is created,

Grégoire
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New segment and mp4mux

killerrats
try putting this.

filesrc location=%s ! qtdemux name=demux ! queue ! h264parse
config-interval=1 ! queue !
mp4mux name=mux ! filesink location=/tmp/a.mp4



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

Re: New segment and mp4mux

Grégoire Gentil
In reply to this post by Grégoire Gentil


On 10/09/2018 10:26 AM, Grégoire Gentil wrote:

> I'm using this test case
>
> https://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/tests/icles/test-segment-seeks.c 
>
>
> and I have simply replaced the pipeline by:
>
> filesrc location=%s ! qtdemux name=demux ! queue ! h264parse ! queue !
> mpegpsmux name=mux ! filesink location=/tmp/a.mp4
>
> This works OK. Here is the full file:
>
> https://pastebin.com/Ue2HRReX
>
>
>
> But if I replace mpegpsmux by mp4mux (everything else unchanged), the
> resulting video is broken. This unfortunately makes sense because the
> timestamps of the video are not correct anymore and mp4mux care about this.
>
> What kind of event am I supposed to send downstream to make happy
> mp4mux? I have tried many things including sending new segment events,
> changing the buffer_dts timestamp in a pad sink callback. Nothing works.
>
> I have read the code of splitmuxsink which faces a similar situation but
> it's also slightly different because the plugin resets when each new
> file is created,
>
> Grégoire


I have tried adding config-interval=1 but the mp4 video is still broken.

Also, the mpegpsmux video is kind of flaky every second with a "shake".

I'm confused what I need to do. Are the timestamps in the mp4 video even
h264parse or is mp4mux taking the timestamp provided in BUFFER_DTS after
h264parse? Could I / should I add a probe callback after h264parse and
edit the timestamp(s) of GstBuffer? I have tried that but it didn't seem
to work.

Grégoire
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New segment and mp4mux

killerrats
EOS the pipeline:

gst-launch-1.0 -e filesrc location=%s ! qtdemux name=demux ! queue ! h264parse ! queue ! mpegpsmux name=mux ! filesink location=/tmp/a.mp4
or
gst_element_send_event(Pipeline, gst_event_new_eos());

editing the timestamps you can do it this way also:
filesrc location=%s ! qtdemux name=demux ! queue ! identity ! h264parse ! queue ! mpegpsmux name=mux ! filesink location=/tmp/a.mp4
C++:
GstElement* identity = gst_bin_get_by_name(GST_BIN(pipeline),"identity0");
g_signal_connect(identity, "handoff", G_CALLBACK(identity_handoff),this->pRtspPipeline);

void identity_handoff(GstElement* element, GstBuffer* buffer, gpointer user_data)
{
	auto pRtspPipe = static_cast<RtspPipeline*>(user_data);
	try
	{
		GstClockTime now;
		GstClockTime base_time;

		now = gst_clock_get_time(gst_element_get_clock(element));
		base_time = gst_element_get_base_time(element);

		if (gst_buffer_is_writable(buffer))
			GST_BUFFER_DTS(buffer) = now - base_time;
	}
	catch (std::exception ex)
	{

	}
}

------------------------------
Gstreamer 1.14.4
------------------------------
Windows


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 1.14.4
------------------------------
Windows
Reply | Threaded
Open this post in threaded view
|

Re: New segment and mp4mux

Grégoire Gentil
In reply to this post by Grégoire Gentil


Date: Thu, 11 Oct 2018 14:23:21 -0500 (CDT)
From: killerrats <[hidden email]>
To: [hidden email]
Subject: Re: New segment and mp4mux
Message-ID: <[hidden email]>
Content-Type: text/plain; charset="utf-8"

EOS the pipeline:
gst-launch-1.0 -e filesrc location=%s ! qtdemux name=demux ! queue !
h264parse ! queue ! mpegpsmux name=mux ! filesink location=/tmp/a.mp4
*or*
gst_element_send_event(Pipeline, gst_event_new_eos());
editing the timestamps you can do it this way also:
filesrc location=%s ! qtdemux name=demux ! queue ! identity ! h264parse !
queue ! mpegpsmux name=mux ! filesink location=/tmp/a.mp4
C++:
GstElement* identity = gst_bin_get_by_name(GST_BIN(pipeline),"identity0");
g_signal_connect(identity, "handoff",
G_CALLBACK(identity_handoff),this->pRtspPipeline);
void identity_handoff(GstElement* element, GstBuffer* buffer, gpointer
user_data){ auto pRtspPipe = static_cast<RtspPipeline*>(user_data); try {
GstClockTime now; GstClockTime base_time; now =
gst_clock_get_time(gst_element_get_clock(element)); base_time =
gst_element_get_base_time(element); if (gst_buffer_is_writable(buffer))
GST_BUFFER_DTS(buffer) = now - base_time; } catch (std::exception ex) { }}





Even with the identity element and messing the DTS in a good way to
"align" them, it's not working. Even if I do decodebin ! x264enc instead
of h264parse (in order to remove anything in the video container), it's
not working. And even if I do:

start in pause mode
wait for preroll
seek to 0
wait for preroll
playing

it's not working and the mp4 file is not valid.

So there is something else that touches the mp4mux element when there is
a seek,

Grégoire

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