How to reset time in elements when pipeline is running ?

stic at free.fr stic at free.fr
Mon Sep 15 16:26:09 PDT 2014


Still stuck trying to record my stream to a file while it is playing...
Still didn't found how to have good timestamps with audio (MP3) + video (MPEG4) on matroska format.
I now try to record it to mp4 file format, the file is created, but the file is not playable in gstreamer (though I can play it fine only with VLC: there is no timestamp issue, and audio and video is well played and synchronised).

I encountered following logs when playing file with gstreamer (I had only warnings in logs, no error):
W/GStreamer+qtdemux(11625): 0:00:34.263400000 0x6c5dadb0 qtdemux.c:4776:gst_qtdemux_chain:<qtdemux0> Unknown fourcc while parsing header : free
W/GStreamer+qtdemux(11625): 0:00:34.276691999 0x6c5dadb0 qtdemux_types.c:196:qtdemux_type_get unknown QuickTime node type .mp3
W/GStreamer+qtdemux(11625): 0:00:34.277396999 0x6c5dadb0 qtdemux_types.c:196:qtdemux_type_get unknown QuickTime node type XMP_
W/GStreamer+qtdemux(11625): 0:00:34.295554999 0x6c5dadb0 qtdemux_dump.c:817:qtdemux_node_dump_foreach             not enough data parsing atom stsd
W/GStreamer+qtdemux(11625): 0:00:34.296185999 0x6c5dadb0 qtdemux_types.c:196:qtdemux_type_get unknown QuickTime node type .mp3
W/GStreamer+qtdemux(11625): 0:00:34.305416999 0x6c5dadb0 qtdemux_types.c:196:qtdemux_type_get unknown QuickTime node type XMP_
W/GStreamer+qtdemux(11625): 0:00:34.306227999 0x6c5dadb0 qtdemux.c:6740:qtdemux_parse_segments:<qtdemux0> streaming; discarding edit list segments
W/GStreamer+qtdemux(11625): 0:00:34.308269999 0x6c5dadb0 qtdemux.c:6740:qtdemux_parse_segments:<qtdemux0> streaming; discarding edit list segments

I am wondering if the file metadata have been properly written while sending the eos event... but really tried everything I could !!

Anyone there please ?
Thanks again.


----- Mail original -----
De: stic at free.fr
À: "Discussion of the development of and with GStreamer" <gstreamer-devel at lists.freedesktop.org>
Envoyé: Vendredi 12 Septembre 2014 18:25:45
Objet: Re: How to reset time in elements when pipeline is running ?

Found an old bugzilla (https://bugzilla.gnome.org/show_bug.cgi?id=561224) that talks about what I would like to do.
But I have audio in addition to video and it seems this is what causes me such difficulties.
Also It talks about setting pad offset...
Anyone to provide me a clue or something ? :/


----- Mail original -----
De: stic at free.fr
À: "Discussion of the development of and with GStreamer" <gstreamer-devel at lists.freedesktop.org>
Envoyé: Vendredi 12 Septembre 2014 14:47:58
Objet: Re: How to reset time in elements when pipeline is running ?

little mistake in the code I sent:
the line code "//GST_BUFFER_PTS (buffer) -= data->recordVideoBufferOffset;" is not commented.


----- Mail original -----
De: stic at free.fr
À: "Discussion of the development of and with GStreamer" <gstreamer-devel at lists.freedesktop.org>
Envoyé: Vendredi 12 Septembre 2014 13:42:02
Objet: How to reset time in elements when pipeline is running ?

Hello,

I am now able to dynamically add/remove elements to my pipeline on video and audio queues, this in order to add when needed recording of the running pipeline to a file.
But I am now facing the issue where I need to re timestamp the buffers, else the resulting recorded file (matroska format) doesn't start from 0, and is not well seekable.

I tried two following methods:

1 - I tried resetting buffer timestamp with buffer probe callback, one probe for video, another for audio:

I launch the buffer probe like this:
  data->recordVideoBufferOffset = 0;
  gst_pad_add_probe (videosrcpad, GST_PAD_PROBE_TYPE_BUFFER, record_video_buffer_pad_probe_cb, data, NULL);
And I do the same for the audio branch:
  data->recordAudioBufferOffset = 0;
  gst_pad_add_probe (audiosrcpad, GST_PAD_PROBE_TYPE_BUFFER, record_audio_buffer_pad_probe_cb, data, NULL);

Then the callback function are the following (The second callback function for audio is similar):
  /* callback to modify buffers timestamp while recording */
  static GstPadProbeReturn
  record_video_buffer_pad_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
  {
    CustomData *data = (CustomData *)user_data;
    GstBuffer *buffer;
    GstBufferFlags flags;
  
    buffer = GST_PAD_PROBE_INFO_BUFFER(info);
    buffer = gst_buffer_make_writable(buffer);
    flags = GST_BUFFER_FLAGS(buffer);
    GST_PAD_PROBE_INFO_DATA(info) = buffer;

    if (!(flags & GST_BUFFER_FLAG_DELTA_UNIT)) {
      // save current buffer timestamp as reference
      if (data->recordVideoBufferOffset == 0) {
    	  data->recordVideoBufferOffset = GST_BUFFER_PTS (buffer);
      }
    }
  
    //GST_BUFFER_PTS (buffer) -= data->recordVideoBufferOffset;
    return GST_PAD_PROBE_PASS;
  }

==> This works when I have only video in my stream (video time starts well from 0 now), but as soon as I have audio+video it doesn't work anymore, the resulting file is not properly playable or its playback time doesn't start from 0.

2 - I tried also to reset time using gst_pad_set_offset function, using elapsed time of pipeline as the offset:

  // update pad offset to change its time
  GstClock * elementClock = gst_element_get_clock (GST_ELEMENT(data->play_pipeline));
  GstClockTime elementBaseTime = gst_element_get_base_time (GST_ELEMENT(data->play_pipeline));  
  // Calculate the elapsed time
  GstClockTime diff = gst_clock_get_time(elementClock) - elementBaseTime;
  // set it as offset
  gst_pad_set_offset (videosrcpad, diff);
  gst_pad_set_offset (audiosrcpad, diff);

==> But this doesn't seem to have any effect. Anyway it doesn't work as I want.


So can someone please give me some advices on how to achieve this ??? And can't find any information about this, mainly when we need to do this with audio+video.
I am really stuck with this and it seems my problem is with synchronising audio timestamps with video timestamps, as the first method works with video alone.

Any help would be really appreciated.
Thanks and regards.
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
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