Given following pipeline "rtspsrc ! decodebin ! jpegenc ! appsink" (code on C# below). How can I get camera timestamp (I mean real(or physical) camera time, when the camera itself captured the image, not pts or dts)? I'm not very familiar with this domain or gstreamer, just started to learn. Also I saw this answer, it is very helpful, at least I got some keywords to look for( RTCPBuffer, RTCPPacket) but still I don't know how to do this with gstreamer-sharp lib. In code below I use appsink, so I hope to get data(needed ts) from NewSample event handler.
Here is code:
private static Pipeline BuildRtspPipe()
{
// Build the pipeline
var rtspSrc = ElementFactory.Make("rtspsrc", "rtspsrc");
rtspSrc["location"] = "rtsp://someaddr";
var dec = ElementFactory.Make("decodebin", "decodebin");
var jpegenc = ElementFactory.Make("jpegenc", "jpegenc");
var appSink = new AppSink("");
appSink.NewSample += AppSink_NewSample;
appSink.EmitSignals = true;
var pipeline = new Pipeline("test");
pipeline.Add(rtspSrc, dec, jpegenc, appSink);
if ( !rtspSrc.Link(dec) )
{
Console.WriteLine("Could not link pipeline elements");
}
rtspSrc.PadAdded += (o, args) =>
{
var decpad = dec.GetStaticPad("sink");
if (decpad.IsLinked)
{
return;
}
args.NewPad.Link(decpad);
};
dec.PadAdded += (o, args) =>
{
var jpegencpad = jpegenc.GetStaticPad("sink");
if (jpegencpad.IsLinked)
{
return;
}
var caps = args.NewPad.QueryCaps();
if (caps == null)
return;
args.NewPad.Link(jpegencpad);
};
if (!Element.Link(jpegenc, appSink))
{
Console.WriteLine("Could not link pipeline elements");
throw new Exception();
}
return pipeline;
}
Thanks in advance.
Seems that answer to my question is here -- https://stackoverflow.com/a/75799182/241446
Need add probe to sink buffer, like
foreach (Pad pad in splitmuxsink.Pads)
{
if (pad.Direction == PadDirection.Sink)
{
pad.AddProbe(PadProbeType.Buffer, (pad, probeInfo) =>
{
var buf = probeInfo.Buffer;
var metaTs = buf.GetReferenceTimestampMeta();
if (metaTs.Timestamp > 0)
{
System.Diagnostics.Debug.WriteLine($"probe counter: {probeCounter}");
}
System.Diagnostics.Debug.WriteLine($"splitmuxsink element, buffer ts: {metaTs.Timestamp}");
return PadProbeReturn.Ok;
});
}
}
Btw, there is thread with more details, especially with network part --https://lists.freedesktop.org/archives/gstreamer-devel/2023-July/081546.html