[Bug 769713] New: Unable to write multiple simultaneous filesinks from appsrc.

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Wed Aug 10 20:30:30 UTC 2016


https://bugzilla.gnome.org/show_bug.cgi?id=769713

            Bug ID: 769713
           Summary: Unable to write multiple simultaneous filesinks from
                    appsrc.
    Classification: Platform
           Product: GStreamer
           Version: 1.8.2
                OS: Mac OS
            Status: NEW
          Severity: normal
          Priority: Normal
         Component: gstreamer (core)
          Assignee: gstreamer-bugs at lists.freedesktop.org
          Reporter: tyler at pictretail.com
        QA Contact: gstreamer-bugs at lists.freedesktop.org
     GNOME version: ---

I'm having trouble saving from appsrc to filesink when I have multiple
gstreamer processes running simultaneously. Only one of the gstreamer processes
will write correctly  while the others will all write nearly empty files. There
appears to be write contention during the filesink operation.

Note: I am using gstreamer1.0 (v1.8.2) with python3 (v3.5.2) on MAC OS 10.11.6.


Here's what my code is actually doing:

In the background, I am reading in frames from a single video stream,
converting each frame to BGR numpy arrays of size 1920x800x3, and storing each
frame in a circular buffer. I have built a "gstreamer_writer function" that
reads frames from this circular buffer, converts the frames into a byte stream,
and feeds this stream into appsrc. 

This works by instantiating a new multiprocess (multiprocessing.Process) and
pointing this at the "gstreamer_writer function". This works completely fine
for a single multiprocess/function call.  Appsrc is correctly fed the byte
stream and I save these BGR frames into a mp4 with h264 encoding using the
following gstreamer pipeline:

appsrc format=3 name=app emit-signals=true do-timestamp=true is-live=true
blocksize=4608000 max-bytes=0 caps=video/x-raw,format=BGR,width=1920,height=800
! videoconvert ! video/x-raw,format=I420,width=1920,height=800 ! vtenc_h264 !
mp4mux ! filesink location=test1.mp4

However, if I instantiate two or more multiprocesses and point them at the
function only one of filesinks will work properly. For example, if one is
writing to "test1.mp4" and the other is writing to "test2.mp4" then one of the
videos will be written correctly and the other will fail and write a nearly
empty mp4 (~500kb). It's not always the same mp4, 50% of the time test1.mp4
gets written correctly and 50% of the time test2.mp4 gets written correctly. It
looks like there is some kind of race condition or write contention that is
preventing both mp4s from being written to file properly.

One thing to note is that each multiprocess is accessing the same frames from
the same ring buffer. I thought this may have been causing problems with
gstreamer. However, if I display the streams with autovideosink instead of
writing them to file, I can display as many streams/multiprocesses as I'd like.
This means the data is being properly passed through the pipeline and is only
failing during the write stage. I tested this using the gstreamer command:

appsrc format=3 name=app emit-signals=true do-timestamp=true is-live=true
blocksize=4608000 max-bytes=0 caps=video/x-raw,format=BGR,width=1920,height=800
! videoconvert ! video/x-raw,format=I420,width=1920,height=800 ! vtenc_h264 !
avdec_h264 ! autovideosink

If anyone has any suggestions for how I can fix this problem I would appreciate
it. I'm hoping it's a simple change but you never know with gstreamer!

Thanks!

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list