Given some timestamp (probably second or ms precision), I need to exctract closest frame in mp4 file with assumed camera timestamp(captured time, not pts or dts) for each frame, what is a more appropriate pipeline to exctract each frame within it's captured timestamp (smth like to use GetReferenceTimestampMeta from buffer)? Given that I work via gstreamer-sharp I expect to use appsink events, smth like:
private static void AppSink_NewSample(object o, NewSampleArgs args)
{
if (o is AppSink aps)
{
var sample = aps.PullSample();
var buf = sample.Buffer;
buf.Map(out var info, MapFlags.Read);
//application/x-rtp
var tsMeta = buf.GetReferenceTimestampMeta();
//NOTE tsMeta shouldn't be null there...
//TODO some timestamps compare logic
buf.Unmap(info);
}
Counter++;
}
Put it simple -- I need to iterate over frames and select one based on some condition (actually, closest to given timestamp).
Thanks in advance.
I found the way, it is smth like:
var appSink = (AppSink) readerPipe.GetByName("my_appsink");
readerPipe.SetName($"frame_stepper");
var q = readerPipe.SetState(State.Playing);
var step = 1;
while (step < frameNumber)
{
appSink.PullSample();
step++;
}