gst-launch -e flag causes usb camera disconnection

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

gst-launch -e flag causes usb camera disconnection

Rafael Sierra
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.

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/GstV4l2Src: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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst-launch -e flag causes usb camera disconnection

Nicolas Dufresne-5


Le 10 mars 2017 1:52 AM, "Rafael Sierra" <[hidden email]> 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/GstV4l2Src: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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst-launch -e flag causes usb camera disconnection

Rafael Sierra
In reply to this post by Rafael Sierra
Hi

Just a quick update on this issue.

On 2017年03月10日 15:38, Rafael Sierra wrote:

> 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.
>
> 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?

It's been I while since I found the issue. In the mean time I have
tested a few environments with these results:

- The issue only happens with the Logitech C920 (Exact model is Logicool
C920r)
- The issue happens on different PCs / models: Desktop / notebook /
Intel NUC
- The issue happens on different OS versions: Ubuntu 16.04 / 16.10 / 17.04
- The issue also happens on latest GStreamer release (1.12) as well as
1.8.3.

Additionally, take the following pipeline:
$ gst-launch-1.0 -e v4l2src device=/dev/video0 ! autovideosink

It has different behaviors depending on how I stop it:
- If I send SIGINT (Ctrl-C) on the terminal, the issue occurs.
- If I close the window created by autovideosink, the issue _doesn't_ occur.

These different behaviors make me thing this is not a driver issue, but
something not being handled properly within gst-launch.
I believe this is a bug so I'm preparing a bug report I'll try to post ASAP.

If anybody in the list  can confirm the issue I'd appreciate it.

Thanks,
Rafael

>
> 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/GstV4l2Src: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
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: gst-launch -e flag causes usb camera disconnection

Nicolas Dufresne-5
Le lundi 19 juin 2017 à 12:41 +0900, Rafael Sierra a écrit :

> It's been I while since I found the issue. In the mean time I have 
> tested a few environments with these results:
>
> - The issue only happens with the Logitech C920 (Exact model is
> Logicool 
> C920r)
> - The issue happens on different PCs / models: Desktop / notebook / 
> Intel NUC
> - The issue happens on different OS versions: Ubuntu 16.04 / 16.10 /
> 17.04
> - The issue also happens on latest GStreamer release (1.12) as well
> as 
> 1.8.3.
>
> Additionally, take the following pipeline:
> $ gst-launch-1.0 -e v4l2src device=/dev/video0 ! autovideosink
>
> It has different behaviors depending on how I stop it:
> - If I send SIGINT (Ctrl-C) on the terminal, the issue occurs.
> - If I close the window created by autovideosink, the issue _doesn't_
> occur.
>
> These different behaviors make me thing this is not a driver issue,
> but 
> something not being handled properly within gst-launch.
> I believe this is a bug so I'm preparing a bug report I'll try to
> post ASAP.
Indeed, this looks like a firmware issue. As described on the bug you
just filed, with CTRL+C en -e (EOS) there is a quick sequence of
operation on the camera that seems to trigger a crash in the Logitech
Firmware, leaving the camera unresponsive.

Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: gst-launch -e flag causes usb camera disconnection

Rafael Sierra

On 2017年06月20日 00:02, Nicolas Dufresne wrote:

> Le lundi 19 juin 2017 à 12:41 +0900, Rafael Sierra a écrit :
>> Additionally, take the following pipeline:
>> $ gst-launch-1.0 -e v4l2src device=/dev/video0 ! autovideosink
>>
>> It has different behaviors depending on how I stop it:
>> - If I send SIGINT (Ctrl-C) on the terminal, the issue occurs.
>> - If I close the window created by autovideosink, the issue _doesn't_
>> occur.
> Indeed, this looks like a firmware issue. As described on the bug you
> just filed, with CTRL+C en -e (EOS) there is a quick sequence of
> operation on the camera that seems to trigger a crash in the Logitech
> Firmware, leaving the camera unresponsive.

Thanks a lot for the follow up. I get this is a firmware/v4l2 issue.

I have one last question about using autovideosink: What could this
element be doing that it avoids this issue?

I'm thinking perhaps I could replicate this behavior in my own pipeline.

Any advice is appreciated.

Thanks,

Rafael
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel