Muxing MPEG4-ES stream into a MOV file

Nicholas Butts nbutts at
Wed Aug 17 11:55:44 PDT 2011

I'm trying to use gstreamer to mux data from a hardware MPEG4-ES encoder
into an MOV file. My code is based off the hello world program. The code is
listed below. When I run this code I get the following error message:

Now playing: 2010_12_17_Good.m4v
Error: Could not multiplex stream.
Returned, stopping playback
Deleting pipeline

Is there a way to do this?

main (int   argc,
      char *argv[])
  GMainLoop *loop;

  GstElement *pipeline, *source, *parse, *muxer, *sink;
  GstBus *bus;

  /* Initialisation */
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

  /* Check input arguments */
  if (argc != 3) {
    g_printerr ("Usage: %s <input mpeg4-es> <output avi>\n", argv[0]);
    return -1;

  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("audio-player");
  source   = gst_element_factory_make ("filesrc",       "file-source");
  parse    = gst_element_factory_make ("mpeg4videoparse",
  muxer    = gst_element_factory_make ("qtmux",      "qt-muxer");
  //decoder  = gst_element_factory_make ("vorbisdec",     "vorbis-decoder");
  //conv     = gst_element_factory_make ("audioconvert",  "converter");
  sink     = gst_element_factory_make ("filesink", "file-output");

  if (!pipeline || !source || !parse || !muxer || !sink) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;

  /* Set up the pipeline */

  /* we set the input filename to the source element */
  g_object_set (G_OBJECT (source), "location", argv[1], NULL);
  g_object_set (G_OBJECT (sink), "location", argv[2], NULL);

  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  /* we add all elements into the pipeline */
  /* file-source | ogg-demuxer | vorbis-decoder | converter | alsa-output */
  gst_bin_add_many (GST_BIN (pipeline),
                    source, parse, muxer, sink, NULL);

  /* we link the elements together */
  /* file-source -> ogg-demuxer ~> vorbis-decoder -> converter ->
alsa-output */
  gst_element_link (source, parse);
  gst_element_link (parse, muxer);
  gst_element_link (muxer, sink);
  //g_signal_connect (muxer, "pad-added", G_CALLBACK (on_pad_added),

  /* note that the demuxer will be linked to the decoder dynamically.
     The reason is that Ogg may contain various streams (for example
     audio and video). The source pad(s) will be created at run time,
     by the demuxer when it detects the amount and nature of streams.
     Therefore we connect a callback function which will be executed
     when the "pad-added" is emitted.*/

  /* Set the pipeline to "playing" state*/
  g_print ("Now playing: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);

  /* Out of the main loop, clean up nicely */
  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);

  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));

  return 0;

Nicholas Butts

Appareo Systems, LLC
1810 NDSU Research Circle N
Fargo, ND 58102

P: (701) 356-2200
F: (701) 356-3157

nbutts at

NOTICE: This message {including attachments} is covered by the Electronic
Communication Privacy Act, 18 U.S.C. sections 2510-2521, is CONFIDENTIAL and
may also be protected by ATTORNEY-CLIENT OR OTHER PRIVILEGE. If you believe
that it has been sent to you in error, do not read it. If you are not the
intended recipient, you are hereby notified that any retention,
dissemination, distribution, or copying of this communication is strictly
prohibited. Please reply to the sender that you have received the message in
error and then delete it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list