Playbin -> play audio and video + record it to a file

stic at free.fr stic at free.fr
Tue Apr 8 11:31:15 PDT 2014


ok, here is a piece of the code i try to use. You can just paste it the app_function of your Android tutorial5 ...
Video is played, not Audio ... and there is an error saying no decoder is available for audio.

/////////////////////START

  GstElement *videotee, *audiotee, *videoqueue, *audioqueue, *intervideoqueue, *interaudioqueue, *intervideosink, *interaudiosink, *videosink, *audiosink;
  // Create the elements inside the sink bin
  videotee = gst_element_factory_make ("tee", "videotee");
  audiotee = gst_element_factory_make ("tee", "audiotee");
  videoqueue = gst_element_factory_make ("queue", "videoqueue");
  audioqueue = gst_element_factory_make ("queue", "audioqueue");
  intervideoqueue = gst_element_factory_make ("queue", "intervideoqueue");
  interaudioqueue = gst_element_factory_make ("queue", "interaudioqueue");
  intervideosink = gst_element_factory_make ("intervideosink", "intervideosink");
  interaudiosink = gst_element_factory_make ("interaudiosink", "interaudiosink");
  
  videosink = gst_element_factory_make ("autovideosink", "videosink");
  audiosink = gst_element_factory_make ("autoaudiosink", "audiosink");
  
  if (!videotee || !audiotee || !videoqueue || !audioqueue || !intervideoqueue || !interaudioqueue || !intervideosink || !interaudiosink || !videosink || !audiosink) {
    GST_ERROR ("Not all elements could be created.\n");
    return NULL;
  }

  // Configure intervideosink
  g_object_set (G_OBJECT (intervideosink), "sync", TRUE, NULL);
  // Configure interaudiosink
  g_object_set (G_OBJECT (interaudiosink), "sync", TRUE, NULL);
   
  // Create the video sink bin, add the elements and link them
  GstElement *videobin;
  videobin = gst_bin_new ("video_sink_bin");
  gst_bin_add_many (GST_BIN (videobin), videotee, videoqueue, intervideoqueue, videosink, intervideosink, NULL);
  gst_element_link_many (videoqueue, videosink, NULL);
  gst_element_link_many (intervideoqueue, intervideosink, NULL);
  
  // Create and link tee with the 2 queues
  GstPadTemplate *tee_src_pad_template;
  GstPad *tee_q1_pad, *tee_q2_pad;
  GstPad *q1_pad, *q2_pad;
  // video tee ...
  tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (videotee), "src_%u");
  // Obtaining request pads for the tee elements
  tee_q1_pad = gst_element_request_pad (videotee, tee_src_pad_template, NULL, NULL);
  GST_INFO ("Obtained request pad %s for q1 branch.", gst_pad_get_name (tee_q1_pad));
  q1_pad = gst_element_get_static_pad (videoqueue, "sink");
  tee_q2_pad = gst_element_request_pad (videotee, tee_src_pad_template, NULL, NULL);
  GST_INFO ("Obtained request pad %s for q2 branch.", gst_pad_get_name (tee_q2_pad));
  q2_pad = gst_element_get_static_pad (intervideoqueue, "sink");

  // Link the tee to the queue 1
  if (gst_pad_link (tee_q1_pad, q1_pad) != GST_PAD_LINK_OK ){
	GST_ERROR ("Tee for q1 could not be linked.");
	gst_object_unref (data->pipeline);
	return NULL;
  }

  // Link the tee to the queue 2
  if (gst_pad_link (tee_q2_pad, q2_pad) != GST_PAD_LINK_OK) {
	GST_ERROR ("Tee for q2 could not be linked.\n");
	gst_object_unref (data->pipeline);
	return NULL;
  }
  
  gst_object_unref (q1_pad);
  gst_object_unref (q2_pad);
  // end video tee
  
  // Create the audio sink bin, add the elements and link them
  GstElement *audiobin;
  audiobin = gst_bin_new ("audio_sink_bin");
  gst_bin_add_many (GST_BIN (audiobin), audiotee, audioqueue, interaudioqueue, audiosink, interaudiosink, NULL);
  gst_element_link_many (audioqueue, audiosink, NULL);
  gst_element_link_many (interaudioqueue, interaudiosink, NULL);
  
  // Create and link tee with the 2 queues
  // audio tee ...
  tee_src_pad_template = gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (audiotee), "src_%u");
  // Obtaining request pads for the tee elements
  tee_q1_pad = gst_element_request_pad (audiotee, tee_src_pad_template, NULL, NULL);
  GST_INFO ("Obtained request pad %s for q1 branch.", gst_pad_get_name (tee_q1_pad));
  q1_pad = gst_element_get_static_pad (audioqueue, "sink");
  tee_q2_pad = gst_element_request_pad (audiotee, tee_src_pad_template, NULL, NULL);
  GST_INFO ("Obtained request pad %s for q2 branch.", gst_pad_get_name (tee_q2_pad));
  q2_pad = gst_element_get_static_pad (interaudioqueue, "sink");

  // Link the tee to the queue 1
  if (gst_pad_link (tee_q1_pad, q1_pad) != GST_PAD_LINK_OK ){
	GST_ERROR ("Tee for q1 could not be linked.");
	gst_object_unref (data->pipeline);
	return NULL;
  }

  // Link the tee to the queue 2
  if (gst_pad_link (tee_q2_pad, q2_pad) != GST_PAD_LINK_OK) {
	GST_ERROR ("Tee for q2 could not be linked.\n");
	gst_object_unref (data->pipeline);
	return NULL;
  }
  
  gst_object_unref (q1_pad);
  gst_object_unref (q2_pad);
  // end audio tee
  
  // get sink of video tee and set is as pad of the BIN
  GstPad *sinkpad, *ghost_sinkpad;
  sinkpad = gst_element_get_static_pad (videotee, "sink");
  ghost_sinkpad = gst_ghost_pad_new ("sink", sinkpad);
  gst_pad_set_active (ghost_sinkpad, TRUE);
  gst_element_add_pad (videobin, ghost_sinkpad);
  gst_object_unref (sinkpad);
  
  // get sink of audio tee and set is as pad of the BIN
  sinkpad = gst_element_get_static_pad (audiotee, "sink");
  ghost_sinkpad = gst_ghost_pad_new ("sink", sinkpad);
  gst_pad_set_active (ghost_sinkpad, TRUE);
  gst_element_add_pad (audiobin, ghost_sinkpad);
  gst_object_unref (sinkpad);
  
  // Set playbin's video sink to be our video sink bin
  g_object_set (GST_OBJECT (data->pipeline), "video-sink", videobin, NULL);
  // Set playbin's audio sink to be our audio sink bin
  // THIS FAILS!
  g_object_set (GST_OBJECT (data->pipeline), "audio-sink", audiobin, NULL);

/////////////////////END

----- Mail original -----
De: "Sebastian Dröge" <sebastian at centricular.com>
À: "Discussion of the development of and with GStreamer" <gstreamer-devel at lists.freedesktop.org>
Envoyé: Mardi 8 Avril 2014 19:57:12
Objet: Re: Playbin -> play audio and video + record it to a file

On Di, 2014-04-08 at 19:17 +0200, stic at free.fr wrote:
> I'm still not able to use inter elements ... but anyway, for now whatever i try to do i always fail with a message from decodebin element coming from playbin:
> gsturidecodebin.c:930:unknown_type_cb:<uridecodebin0> warning: No decoder available for type 'audio/AMR, codec_data=(buffer)0000001164616d7270766d6d0001800001, rate=(int)8000, channels=(int)1'.
> 
> My problem is with audio.
> I tried with different audio format, and whatever codec it is it says there is no decoder available for audio as soon as i try to use an autoaudiosink that is not coming from playbin as default.
> So when i specify a bin to 'audio-sink' property of playbin, then it fails with that kind of error.
> I do exactly the same thing for 'video-sink' and there is no issue with video. Video is properly played to the custom autovideosink inside my bin.
> 
> If I left things as default (no use of 'audio-sink') there is no error and audio is played ...
> 
> Please can anyone provide any help about this ? I'm really really desperate :/ ...

Can you provide a simple, minimal testcase for this audio-sink problem?
That seems really weird.

-- 
Sebastian Dröge, Centricular Ltd - http://www.centricular.com
Expertise, Straight from the Source

_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


More information about the gstreamer-devel mailing list