GStreamer qtmux/mp4mux command to code converting

1.1k views Asked by At

I'm using qtmux to merge audio and video to mp4 container file with GStreamer. My pipeline looks like:

gst-launch-1.0 autovideosrc ! x264enc ! queue ! qtmux0. autoaudiosrc! wavenc ! queue ! qtmux ! filesink location=file.mp4

videotestsrc --> x264enc -----\
                               >---> qtmux ---> filesink
audiotestsrc --> wavenc ------/ 

It's working good with commandline. But I want to code it in C code. I was stuck in this part:

x264enc -----\
              >---> qtmux
wavenc ------/ 

This is codes for this part.

  gst_element_link_many(audiosource, wavenc, audioqueue, NULL);
  gst_element_link_many(videosource, x264enc, videoqueue, NULL);
  gst_element_link_many(qtmux, filesink, NULL);
  
  audio_pad     =  gst_element_get_request_pad (audioqueue, "src");
  mux_audio_pad = gst_element_get_static_pad (qtmux, "sink_1");
  gst_pad_link (audio_pad,mux_audio_pad); **# ERROR HERE**

  video_pad     = gst_element_get_request_pad (videoqueue, "src");
  mux_video_pad = gst_element_get_static_pad(qtmux, "sink_2");
  gst_pad_link (video_pad,mux_video_pad); **# ERROR HERE**

But it's wrong in step link pads. And the error type: GST_PAD_LINK_NOFORMAT (-4) – pads do not have common format

How can I fix it ?

1

There are 1 answers

3
Florian Zwoch On BEST ANSWER

I think you have switches request/static pad calls here. The queue should have static pads while the muxer has request pads.

You can also make your life easier by using gst_parse_launch() function to create a pipeline as you do on the command line therefore saving a lot of error prone code.