Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
237 views
in Technique[技术] by (71.8m points)

GStreamer tee + x264enc first frame duration is not correct

I have live stream source, and I want to start recording the stream from arbitrary time. My setup is like this:

videotestsrc ! tee name=rawVideoSplitter ! queue ! ximagesink

And I start the recording by linking encoder bin to the "tee":

        recorderBranch = gst_parse_bin_from_description("queue name=recorderQueue flush-on-eos=1 leaky=1 ! "
            "timeoverlay shading-value=255 shaded-background=true font-desc="Sans, 10" time-mode=0 ! "
            "videorate ! video/x-raw,framerate=30/1 ! videoconvert ! "
            "x264enc tune=zerolatency ! mp4mux ! filesink name=fileSink location=test.mp4", true, &error);

        if (error) {
            recorderBranch = NULL;
            return;
        }

        gst_bin_add(GST_BIN(pipeline), recorderBranch);
        gst_element_link(rawVideoSplitter, recorderBranch);
        gst_element_set_state(GST_ELEMENT(recorderBranch), GST_STATE_PLAYING);

Everything works fine, except the recorded file length is longer the actual recording time. First frame in the file has length of "encoder start time - pipeline start time". For example if I start to record at 10th second to 20th seconds, in playback I get first frame fixed for 10 seconds and then file starts to playback normally.

How I can fix this?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...