gst-launch -e flag causes usb camera disconnection

Nicolas Dufresne nicolas at ndufresne.ca
Fri Mar 10 22:24:09 UTC 2017


Le 10 mars 2017 1:52 AM, "Rafael Sierra" <tt.babyvitals.01 at gmail.com> a
écrit :

Hi

I'm recording MJPEG video from a Logitech C920 USB camera, with this
pipeline:

gst-launch-1.0 -e v4l2src device=/dev/video0 \
   ! image/jpeg,width=1280,height=720,framerate=24/1 \
   ! jpegparse ! avimux ! filesink location=mjpeg-01.avi

I use the -e flag so, according to the documentation, an EOS signal is sent
and the video file is properly created/closed.
The problem is that after I use the -e flag in a pipeline, almost any
subsequent pipeline that access the camera will fail and cause a camera
disconnection, where it needs to be replugged to be usable again. If I
remove the -e flag, there are no problems, but the video file is saved
without an index and is not readily usable.


I'll have to test that. I have never seen such issue. As the GStreamer
process quits, something must be going wrong in your kernel.


Questions:
- Is the pipeline a proper one?
- Is this normal behavior? Or is it a known bug?
- What can I do to avoid the issue with the -e flag? Note that I need it
to record usable video files.
- Would it be worth it to avoid gst-launch and write my pipeline in C/C++,
or would I eventually hit the same issue?

I've tried some debugging and came out with the steps below to reproduce
the issue.
System Configuration: (Ubuntu 16.04.1)

$ uname -a
Linux NUC02 4.4.0-66-generic #87-Ubuntu SMP Fri Mar 3 15:29:05 UTC 2017
x86_64 x86_64 x86_64 GNU/Linux

$ gst-launch-1.0 --version
gst-launch-1.0 version 1.8.3
GStreamer 1.8.3

Camera is /dev/video0. Using the lsusb command between launches ensures the
next pipeline launch will fail, it is not necessary, it just makes it fail
faster.
-------------------------------
# Check camera is present:
ll /dev/vid*
crw-rw----+ 1 root video 81, 0  Mar 10 15:20 /dev/video0

# launch simple pipeline; interrupt it after a few seconds:
$ gst-launch-1.0 -ev v4l2src device=/dev/video0 ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps =
"video/x-raw\,\ format\=\(string\)YUY2\,\ width\=\(int\)2304\,\
height\=\(int\)1536\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\
interlace-mode\=\(string\)progressive\,\ colorimetry\=\(string\)2:4:7:1\,\
framerate\=\(fraction\)2/1"
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.
GstGhostPad:sink.GstProxyPad:proxypad0: caps = "video/x-raw\,\
format\=\(string\)YUY2\,\ width\=\(int\)2304\,\ height\=\(int\)1536\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ interlace-mode\=\(string\)progressive\,\
colorimetry\=\(string\)2:4:7:1\,\ framerate\=\(fraction\)2/1"
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0/
GstXvImageSink:autovideosink0-actual-sink-xvimage.GstPad:sink: caps =
"video/x-raw\,\ format\=\(string\)YUY2\,\ width\=\(int\)2304\,\
height\=\(int\)1536\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\
interlace-mode\=\(string\)progressive\,\ colorimetry\=\(string\)2:4:7:1\,\
framerate\=\(fraction\)2/1"
/GstPipeline:pipeline0/GstAutoVideoSink:autovideosink0.GstGhostPad:sink:
caps = "video/x-raw\,\ format\=\(string\)YUY2\,\ width\=\(int\)2304\,\
height\=\(int\)1536\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\
interlace-mode\=\(string\)progressive\,\ colorimetry\=\(string\)2:4:7:1\,\
framerate\=\(fraction\)2/1"
^Chandling interrupt.
Interrupt: Stopping pipeline ...
EOS on shutdown enabled -- Forcing EOS on the pipeline
Waiting for EOS...
Got EOS from element "pipeline0".
EOS received - stopping pipeline...
Execution ended after 0:00:05.728170506
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...

# check the device is still there (not mandatory): OK:
$ lsusb
Bus 002 Device 003: ID 046d:082d Logitech, Inc. HD Pro Webcam C920
...

#launch same pipeline a second time; now it fails after hanging for a while:
$ gst-launch-1.0 -v v4l2src device=/dev/video0 ! autovideosink
Setting pipeline to PAUSED ...
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not
open device '/dev/video0' for reading and writing.
Additional debug info:
v4l2_calls.c(620): gst_v4l2_open (): /GstPipeline:pipeline0/GstV4l2
Src:v4l2src0:
system error: Device or resource busy
Setting pipeline to NULL ...
Freeing pipeline ...

# ls: the camera is gone; lsusb command will hang. Need to replug
$ ll /dev/vid*
ls: cannot access '/dev/vid*': No such file or directory
-------------------------------------------
Notes:
- I use the -e flag because I need to record proper video files. The above
test uses a simplified pipeline just to show the issue with the flag
- I have similar trouble with two other cameras. These don't disconnect but
the image gets distorted.
  1. VF0560 Live! Cam Optia AF (Creative)
  2. QuickCam Pro for Notebooks (Logitech)


Thank you,
Rafael

_______________________________________________
gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170310/a22f9ed8/attachment-0001.html>


More information about the gstreamer-devel mailing list