<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Although in my code it does not change
      anything of the behaviour, I just found the theoretical solution
      to my idea of skipping frames for faster playback:<br>
      <br>
      "When doing fast forward (rate > 1.0) or fast reverse (rate
      < -1.0) trickmode playback, the GST_SEEK_FLAG_SKIP flag can be
      used to instruct decoders and demuxers to adjust the playback rate
      by skipping frames. This can improve performance and decrease CPU
      usage because not all frames need to be decoded." [1]<br>
      <br>
      [1]
<a class="moz-txt-link-freetext" href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstEvent.html#GstSeekFlags">http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstEvent.html#GstSeekFlags</a><br>
      <br>
      <br>
      On 12/13/2012 01:08 PM, Peter Rennert wrote:<br>
    </div>
    <blockquote cite="mid:50C9D339.5040406@cs.ucl.ac.uk" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">Thanks Juraj these were good tips.<br>
        <br>
        I needed to add a queue before ffdec_h264, but there must not be
        one after ffdec_264. Furthermore, I needed to set sync=false at
        the image sink. However, now it seems as the filesink (or
        qtdemux/h264parse?) is not feeding the data quickly enough. (I
        am just at x2 speed, my disk I/O maximum should far ahead). My
        ffdec_264 sends now the following warning message when I try to
        increase the speed:<br>
        <br>
        0:00:06.193160955  3058      0x27f08f0 WARN           
        videodecoder
        gstvideodecoder.c:2847:gst_video_decoder_alloc_output_frame:<dec>
        failed to get buffer wrong-state<br>
        0:00:06.193239481  3058      0x27f08f0 WARN                 
        ffmpeg gstffmpegviddec.c:1218:gst_ffmpegviddec_frame:<dec>
        ffdec_h264: decoding error (len: -1, have_data: 0)<br>
        <br>
        I got rid of those warnings when I add a queue after the
        filesink.<br>
        <br>
        Still there are problems with my pipeline:<br>
        <br>
        First problem is that the standard speed seems to be twice as
        normal. <br>
        <br>
        Second, although I see that the computations are now spread over
        several cores and I do not get anymore warnings from ffdec_h264
        after keyPress (and respective the seek event), the playback
        speed does not change at all anymore.<br>
        <br>
        I put my test code below. Its in python (my first attempt of
        python and gstreamer), but I think it should be readable for
        people who use C or C++, too. I suspect I might use wrong flags
        in gst.event_new_seek(). <br>
        <br>
        P.S.: just to make it complete for documentation purposes,
        playing a bit around with it and using <br>
        <br>
        self.pipeline.send_event(gst.event_new_seek(self.pbRate,
        gst.FORMAT_TIME,<br>
                    gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_NONE,
        gst.CLOCK_TIME_NONE, <br>
                    gst.SEEK_TYPE_NONE, gst.CLOCK_TIME_NONE))<br>
        <br>
        instead of <br>
        <br>
        self.pipeline.send_event(gst.event_new_seek(self.pbRate,
        gst.FORMAT_TIME,<br>
                    gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_NONE, 0, <br>
                    gst.SEEK_TYPE_NONE, 0))<br>
        <br>
        gives me a python error:<br>
        <br>
        Traceback (most recent call last):<br>
          File "pyGstViewer.py", line 61, in keyPress<br>
            self.increasePlaybackSpeed()<br>
          File "pyGstViewer.py", line 70, in increasePlaybackSpeed<br>
            gst.SEEK_TYPE_NONE, gst.CLOCK_TIME_NONE))<br>
        <br>
        <br>
        ===== CODE =====<br>
        <br>
        import sys, os<br>
        import pygst<br>
        pygst.require("0.10")<br>
        import gst<br>
        import pygtk, gobject<br>
        import gtk<br>
        <br>
        class GTK_Main:<br>
            def __init__(self): <br>
                self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)<br>
                self.window.connect("destroy", gtk.main_quit, "WM
        destroy")<br>
                vbox = gtk.VBox()<br>
                self.window.add(vbox)<br>
                vbox.pack_start(gtk.Label("Please type text"))<br>
                entry = gtk.Entry()<br>
                vbox.pack_start(entry)<br>
                self.window.connect("key-press-event", self.keyPress)<br>
        <br>
                self.window.show_all()<br>
        <br>
                self.pipeline =  gst.parse_launch("filesrc " +<br>
                   
        "location=/home/peter/vid/20121207/00/2012-12-07.00-00-00.mp4 !
        " +<br>
                    "queue ! qtdemux ! h264parse ! queue ! ffdec_h264
        name=dec ! " +<br>
                    "ffmpegcolorspace ! deinterlace ! xvimagesink
        sync=false")<br>
        <br>
                self.dec = self.pipeline.get_by_name("dec")<br>
        <br>
                self.dec.set_property("max-threads", 8);<br>
                 <br>
                self.pbRate = 1<br>
        <br>
                self.pipeline.set_state(gst.STATE_PLAYING)<br>
        <br>
                bus = self.pipeline.get_bus()<br>
                bus.add_signal_watch()<br>
                bus.connect("message", self.onMessage)<br>
        <br>
        <br>
            def keyPress(self, widget, event):<br>
                print "keypress event!!"<br>
                key = gtk.gdk.keyval_name(event.keyval)<br>
                if key == "d":<br>
                    self.increasePlaybackSpeed()<br>
                else:<br>
                    self.decreasePlaybackSpeed()<br>
        <br>
            def increasePlaybackSpeed(self):<br>
                print str(self.pbRate) + " --> " + str(self.pbRate +
        4)<br>
                self.pbRate += 4<br>
                self.pipeline.send_event(gst.event_new_seek(self.pbRate,
        gst.FORMAT_TIME,<br>
                    gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_NONE, 0, <br>
                    gst.SEEK_TYPE_NONE, 0))<br>
                print "increased playback speed!!!"<br>
                <br>
            def decreasePlaybackSpeed(self):   <br>
                self.pbRate -= 2<br>
                self.pipeline.send_event(gst.event_new_seek(self.pbRate,
        gst.FORMAT_TIME,<br>
                    gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_NONE, 0, <br>
                    gst.SEEK_TYPE_NONE, 0))<br>
                print "decreased playback speed!!!"<br>
        <br>
            def onMessage(self, bus, message):<br>
                t = message.type<br>
                if t == gst.MESSAGE_EOS:<br>
                    self.pipeline.set_state(gst.STATE_NULL)<br>
                elif t == gst.MESSAGE_ERROR:<br>
                    self.pipeline.set_state(gst.STATE_NULL)<br>
                    err, debug = message.parse_error()<br>
                    print "Error: %s" % err, debug<br>
        <br>
        GTK_Main()<br>
        gtk.gdk.threads_init()<br>
        gtk.main()<br>
        <br>
        <br>
        <br>
        On 12/13/2012 11:18 AM, Juraj Holtak wrote:<br>
      </div>
      <blockquote
cite="mid:CALnZJ1tzK5+pF8JbGrfcVUiGXz1omUhfwST-EesfZ1TjCjw9Ww@mail.gmail.com"
        type="cite">
        <p>And maybe the xvimagesink should have sync=false set too...
          maybe...</p>
        <div class="gmail_quote">On Dec 13, 2012 12:15 PM, "Juraj
          Holtak" <<a moz-do-not-send="true"
            href="mailto:juraj.holtak@gmail.com">juraj.holtak@gmail.com</a>>

          wrote:<br type="attribution">
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <p>Hi,</p>
            <p>Maybe worth a try:</p>
            <p>Put an "queue" element before and after ffdec_h264 and
              use max-threads=<your_cpu_count>. I imagine it
              worked like this for me but maybe I just had luck...</p>
            <p>Juraj</p>
            <div class="gmail_quote">On Dec 13, 2012 2:03 AM, "Peter
              Rennert" <<a moz-do-not-send="true"
                href="mailto:p.rennert@cs.ucl.ac.uk" target="_blank">p.rennert@cs.ucl.ac.uk</a>>

              wrote:<br type="attribution">
              <blockquote class="gmail_quote" style="margin:0 0 0
                .8ex;border-left:1px #ccc solid;padding-left:1ex"> Dear
                all,<br>
                <br>
                I want to increase the playback of a video quite
                drastically. At the moment I am playing a test video
                sequence with<br>
                <br>
                gst-launch-0.10 filesrc location=/path/to/my.mp4 !
                qtdemux ! h264parse ! ffdec_h264 name=dec !
                ffmpegcolorspace ! deinterlace ! xvimagesink<br>
                <br>
                and at some point the video speed cannot get increased
                further, because it uses only one CPU core to decode the
                video. Gstreamer starts complaining of getting behind
                the timestamps of the stream and crashes.<br>
                <br>
                I could think of two solutions:<br>
                    - Is there a "native" way of making use of more than
                just a single core to decode the video frames? I tried
                to set "max-threads" of ffdec_h264 to 4, but it still
                only uses a single core.<br>
                <br>
                or,<br>
                    - Is there a way of skipping frames? As I need only
                a "effective" framerate on the screen of about 25fps I
                could just decode the frames I need and skip the other
                frames. Then I would not need more CPU power than for
                realtime playback.<br>
                <br>
                or.<br>
                    - Is there a way to split the stream after the
                qtdemux and use several decoders in a kind of decoder
                pool (distribute the frames between them) and unify the
                stream after?<br>
                <br>
                My videos are in H264 format. I am not sure if the
                non-keyframes are encoded with respect to the previous
                frame or with respect to the last key-frame. In that
                case I could try to filter the key-frames and send them
                to every decoder in the pool and decode the any frame
                with that as reference until the next key-frame. With
                some management I could try to merge the output of the
                pool decoder with a input-selector. But that sounds
                bulky :\ So if one knows how to get to one of the first
                two solutions, I would be very happy...<br>
                <br>
                <br>
                Cheers,<br>
                <br>
                Peter<br>
                <br>
                PS I am happy to provide an example video. Maybe
                something is wrong with the encoding there that prevents
                ffdec_h264 to use multiple cores<br>
                _______________________________________________<br>
                gstreamer-devel mailing list<br>
                <a moz-do-not-send="true"
                  href="mailto:gstreamer-devel@lists.freedesktop.org"
                  target="_blank">gstreamer-devel@lists.freedesktop.org</a><br>
                <a moz-do-not-send="true"
                  href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel"
                  target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
              </blockquote>
            </div>
          </blockquote>
        </div>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
gstreamer-devel mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
      </blockquote>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>