H264parse element loses sink pad cap after pipeline start

Hi, I’m new to GStreamer and I’m trying to do a simple mp4 file → autovideosink example.
The pipeline is: filesrc ! qtdemux ! h264parse ! autovideosink.
I know I have to handle the qtdemux automatic src pad, and connect it to h264parse sink pad, but for some reason, the sink pad loses its capability when I start the pipeline.

Here’s the code:

    // Setup elements //
    let source = ElementFactory::make("videotestsrc")
        .name("source")
        .build()?;

    let source2 = ElementFactory::make("filesrc")
        .name("filesrc")
        .build()?;

    let demux = ElementFactory::make("qtdemux")
        .name("mp4demux")
        .build()?;

    let parse = ElementFactory::make("h264parse")
        .name("parse")
        .build()?;

    println!("OUTSIDE PAD ADDED Parse sink {:?}", parse.static_pad("sink").unwrap().query_caps(None));

    let sink = ElementFactory::make("autovideosink")
        .name("sink")
        .build()?;

    // Create pipeline //
    let pipeline = Pipeline::with_name("main");

    // Build the pipeline //
    pipeline.add_many([&source2, &demux, &parse, &sink])?;

    source2.link(&demux)?;
    parse.link(&sink)?;

    let parser_sink_pad = parse.static_pad("sink").unwrap();

    // Set dynamic links //
    demux.connect_pad_added(move |src, src_pad|
    {
        println!("Received new pad {} from {}", src_pad.name(), src.name());

        if parser_sink_pad.is_linked()
        {
            println!("Parse pad is already linked");
            return;
        }

        println!("Connecting pad");

        match src_pad.link(&parser_sink_pad)
        {
            Ok(_) => {},
            Err(e) => { println!("Error linking pad, {}", e); }
        }

    });

    source2.set_property("location", uri);

    pipeline.set_state(State::Playing)?;

/// Bus stuff //

Can someone show me what I did wrong?
Thanks in advance!

Hi, I believe you forgot to choose and link a decoder after h264parse. You don’t have to do this by hand, you can use playbin3 also.

Thanks, it worked!
Do you know why the parser needs to have a decoder on its source in order to keep its capabilities?

It’s not a strict requirement to have a decoder though. It needs a sink, if you only want to have the information and not decode, you can use ... h264parse ! fakesink.