Quantcast

Streaming webcam to .ts file: link error

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

Streaming webcam to .ts file: link error

Dystroxic
Hello,

I have a webcam, and I'm trying to use gstreamer to stream the audio and video to a .ts fifo file. This is the info for the webcam:

Driver Info (not using libv4l2):
        Driver name   : uvcvideo
        Card type     : USB 2.0 Camera
        Bus info      : usb-xhci-hcd.2.auto-1.1.4
        Driver version: 3.10.105
        Capabilities  : 0x84000001
                Video Capture
                Streaming
                Device Capabilities
        Device Caps   : 0x04000001
                Video Capture
                Streaming
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
        Width/Height      : 752/416
        Pixel Format      : 'YUYV'
        Field             : None
        Bytes per Line    : 1504
        Size Image        : 625664
        Colorspace        : Default
        Transfer Function : Default
        YCbCr Encoding    : Default
        Quantization      : Default
Crop Capability Video Capture:
        Bounds      : Left 0, Top 0, Width 752, Height 416
        Default     : Left 0, Top 0, Width 752, Height 416
        Pixel Aspect: 1/1
Streaming Parameters Video Capture:
        Capabilities     : timeperframe
        Frames per second: 20.000 (20/1)
        Read buffers     : 0
                     brightness (int)    : min=-64 max=64 step=1 default=0 value=0
                       contrast (int)    : min=0 max=64 step=1 default=32 value=32
                     saturation (int)    : min=1 max=128 step=1 default=64 value=64
                            hue (int)    : min=-40 max=40 step=1 default=0 value=0
                          gamma (int)    : min=72 max=500 step=1 default=100 value=100
                           gain (int)    : min=0 max=100 step=1 default=0 value=0
           power_line_frequency (menu)   : min=0 max=2 default=1 value=1
                      sharpness (int)    : min=0 max=6 step=1 default=2 value=2
         backlight_compensation (int)    : min=0 max=2 step=1 default=1 value=1


So from this, we see that it's using YUYV format. So then I try to run this command:

gst-launch-1.0 -e -v v4l2src device="/dev/video0" ! 'video/x-raw,format=YUYV,framerate=25/1,width=640,height=360' ! x264enc bitrate=498 ! mpegtsmux ! filesink location=video1.ts

But it gives the error:

WARNING: erroneous pipeline: could not link v4l2src0 to x264enc0

And I cannot figure out why I can't get this to work. I also tried "YUY2" for the format field (based on this chart), and also tried having (fourcc) in the format based on the same chart, but that threw a parsing error.

Any thoughts on how I can get this camera to stream to the file?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming webcam to .ts file: link error

Baby Octopus
Enable verbose mode(-v) and see why you have linking issue. Adding videoconvert before x264enc might help
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming webcam to .ts file: link error

Arjen Veenhuizen
x264enc only takes the following formats on its sink pad:
gst-inspect-1.0 x264enc
format: { (string)Y444, (string)Y42B, (string)I420, (string)YV12, (string)NV12 }

Try to insert a videoconvert between the caps and the encoder and don't forget to insert an h264parse between encoder and mpegtsmux. Furthermore, your pipeline could use a queue in front of the encoder.

All in all, your pipeline should look like this:
gst-launch-1.0 -e -v v4l2src device="/dev/video0" ! 'video/x-raw,format=YUYV,framerate=25/1,width=640,height=360' ! videoconvert ! queue ! x264enc bitrate=498 ! h264parse ! mpegtsmux ! filesink location=video1.ts

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming webcam to .ts file: link error

Dystroxic
Unfortunately, this still doesn't work. The pipeline you wrote gives the error:

WARNING: erroneous pipeline: could not link v4l2src0 to videoconvert0



On May 3, 2017 02:29, "Arjen Veenhuizen [via GStreamer-devel]" <[hidden email]> wrote:
x264enc only takes the following formats on its sink pad:
gst-inspect-1.0 x264enc
format: { (string)Y444, (string)Y42B, (string)I420, (string)YV12, (string)NV12 }

Try to insert a videoconvert between the caps and the encoder and don't forget to insert an h264parse between encoder and mpegtsmux. Furthermore, your pipeline could use a queue in front of the encoder.

All in all, your pipeline should look like this:
gst-launch-1.0 -e -v v4l2src device="/dev/video0" ! 'video/x-raw,format=YUYV,framerate=25/1,width=640,height=360' ! videoconvert ! queue ! x264enc bitrate=498 ! h264parse ! mpegtsmux ! filesink location=video1.ts




If you reply to this email, your message will be added to the discussion below:
http://gstreamer-devel.966125.n4.nabble.com/Streaming-webcam-to-ts-file-link-error-tp4682888p4682895.html
To unsubscribe from Streaming webcam to .ts file: link error, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streaming webcam to .ts file: link error

Nicolas Dufresne-5
In reply to this post by Dystroxic
Le mardi 02 mai 2017 à 14:39 -0700, Dystroxic a écrit :
> So from this, we see that it's using YUYV format. So then I try to
> run this
> command:
>
> gst-launch-1.0 -e -v v4l2src device="/dev/video0" !
> 'video/x-raw,format=YUYV,framerate=25/1,width=640,height=360' !
> x264enc
> bitrate=498 ! mpegtsmux ! filesink location=video1.ts

V4L2 YUYV matches YUY2 in GStreamer. This is the most common webcam
format, so it's better to try and remember. In general though, don't
add format= in your filter, GStreamer will figure-it out for your. You
may need a videoconvert element between the v4l2src and x264enc due to
format incompatibility. See gst-inspect-1.0 x264enc for more details.

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

signature.asc (188 bytes) Download Attachment
Loading...