GStreamer:如何逐帧读取mp4并提取捕获(相机)时间?需要找到最接近给定的 ts 帧

问题描述 投票:0回答:1

给定一些时间戳(可能是秒或毫秒精度),我需要提取最近的帧 在每帧具有假定相机时间戳(捕获时间,不是 pts 或 dts)的 mp4 文件中,什么是更合适的管道来提取捕获时间戳中的每个帧(就像从缓冲区中使用 GetReferenceTimestampMeta 一样)?鉴于我通过 gstreamer-sharp 工作,我希望使用 appsink 事件,例如:

  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++;
    }

简单地说——我需要迭代帧并根据某种条件选择一个帧(实际上,最接近给定的时间戳)。

提前致谢。

c# gstreamer mp4 gstreamer-1.0 gstreamer-sharp
1个回答
0
投票

我找到了方法,就像:

            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++;
            }
© www.soinside.com 2019 - 2024. All rights reserved.