Gstreamer convert and display video v4l2 - tee problems in rust

157 Views Asked by At

I have USB grabber v4l2 source and I want to tee stream to autovideosink and x264enc to file (now as fake black hole)

When I disable one or another branch it works but together Pipeline goes:

Pipeline state changed from Null to Ready
Pipeline state changed from Ready to Paused

and stays there never switches to Playing

gst-launch-1.0 with similar functionality works well.

    gst::Element::link_many(&[&pw_video, &v_caps, &vid_queuey, &vid_tee]).unwrap();
    gst::Element::link_many(&[&vid_queue1, &autovideoconvert, &vid_queuex, &autovideosink]).unwrap();
    gst::Element::link_many(&[&vid_queue2, &autovideoconvert_x264, &vid_queue3, &x264, &vid_queue4, &fake]).unwrap();

    let tee_display_pad = vid_tee.request_pad_simple("src_10").unwrap();
    let vid_queue1_pad = vid_queue1.static_pad("sink").unwrap();

    tee_display_pad.link(&vid_queue1_pad).unwrap();

    let tee_convert_pad = vid_tee.request_pad_simple("src_20").unwrap();
    let vid_queue2_pad = vid_queue2.static_pad("sink").unwrap();

    tee_convert_pad.link(&vid_queue2_pad).unwrap();

How can I use tee in rust properly to have playable pipeline with two branches?

Update: I read some posts about increasing queue size, so I tried for this and then all queues:

    let vid_queue1 = gst::ElementFactory::make("queue")
        .name("queue1")
        .property("max-size-buffers", 5000 as u32)
        .property("max-size-bytes", 1048576000 as u32)
        .property("max-size-time", 60000000000 as u64)
        .build()
        .expect("queue1");

but it didn't help so I tried set zero latency:

    let x264 = gst::ElementFactory::make("x264enc")
        .name("x264")
        .property_from_str("speed-preset", "ultrafast")
        .property_from_str("pass", "qual")
        .property_from_str("tune", "zerolatency")
        .property("quantizer", 0 as u32)
        .property("threads", 8 as u32)
        .build()
        .expect("!x264");

and it works now. But comparable gst-launch-1.0 settings didn't had such option - only queues sizes increased.

Is there any other option than setting zerolatency?

1

There are 1 best solutions below

0
Allan Navarro On

Normally when I experience this kind of issue I set the "async" property to false in both autovideosink and filesink elements.