frameerate issue while capturing and encoding a webcam (UVC/v4l2) stream

Damien Picard picard.damien at gmail.com
Thu Mar 9 16:48:01 UTC 2017


Hi,

I'm currenlty discovering GStreamer and I am looking for a way to capture
and encode my UVC webcam to H264 stream in a MP4 container.

I am able to achieve it using this command :

gst-launch-1.0 -e v4l2src device=/dev/video0 !
'image/jpeg,width=1920,height=1080' !  jpegparse ! jpegdec ! videoconvert !
videorate ! x264enc ! mp4mux ! filesink location=videotestsrc.mp4

It does the job but the resulting videotestsrc.mp4 does not seem to have
the right framerate because the video is "accelerated".
I think it could be caused by two things :
 - The framerate in the resulting video is actually not the good one, but
I'm not able to diagnose and fix it ; do you have some tricks to achieve
this ?
 - The capture step does not capture the whole 30 frames per seconds (for a
reason that I don't understand) and, in the resulting video, only the
captured frames are displayed, at 30 fps ; involving that the video seems
to be accelerated.

Some tests I do :
 - decrease the frame size : leads to the same result
gst-launch-1.0 -e v4l2src device=/dev/video0 !
'image/jpeg,width=640,height=480' !  jpegparse ! jpegdec ! videoconvert !
videorate ! x264enc ! mp4mux ! filesink location=videotestsrc.mp4
 - record with mjpeg-streamer : works fine, the avi is played at 30 fps,
not accelerated (the AVI is definitively too large in MJPEG)
./mjpg_streamer -i 'input_uvc.so -r 1920x1080' -o 'output_file.so -f
/home/dams -m video.avi'


The debug output, in 1920x1080 :

Définition du pipeline à PAUSED...
Le pipeline est actif et n’a pas besoin de phase PREROLL…
Passage du pipeline à la phase PLAYING…
New clock: GstSystemClock
/GstPipeline:pipeline0/GstV4l2Src:v4l2src0.GstPad:src: caps =
"image/jpeg\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ colorimetry\=\(string\)2:4:7:1\,\
framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps =
"image/jpeg\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ colorimetry\=\(string\)2:4:7:1\,\
framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstJpegParse:jpegparse0.GstPad:sink: caps =
"image/jpeg\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ colorimetry\=\(string\)2:4:7:1\,\
framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps =
"image/jpeg\,\ width\=\(int\)1920\,\ height\=\(int\)1080\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ colorimetry\=\(string\)2:4:7:1\,\
framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstJpegParse:jpegparse0.GstPad:src: caps =
"image/jpeg\,\ parsed\=\(boolean\)true\,\ format\=\(string\)UYVY\,\
width\=\(int\)1920\,\ height\=\(int\)1080\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:sink: caps =
"image/jpeg\,\ parsed\=\(boolean\)true\,\ format\=\(string\)UYVY\,\
width\=\(int\)1920\,\ height\=\(int\)1080\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstJpegDec:jpegdec0.GstPad:src: caps =
"video/x-raw\,\ format\=\(string\)I420\,\ width\=\(int\)1920\,\
height\=\(int\)1080\,\ interlace-mode\=\(string\)progressive\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ chroma-site\=\(string\)mpeg2\,\
colorimetry\=\(string\)1:4:0:0\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:src: caps =
"video/x-raw\,\ format\=\(string\)I420\,\ width\=\(int\)1920\,\
height\=\(int\)1080\,\ interlace-mode\=\(string\)progressive\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ chroma-site\=\(string\)mpeg2\,\
colorimetry\=\(string\)1:4:0:0\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstVideoRate:videorate0.GstPad:src: caps =
"video/x-raw\,\ format\=\(string\)I420\,\ width\=\(int\)1920\,\
height\=\(int\)1080\,\ interlace-mode\=\(string\)progressive\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ chroma-site\=\(string\)mpeg2\,\
colorimetry\=\(string\)1:4:0:0\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstX264Enc:x264enc0.GstPad:sink: caps =
"video/x-raw\,\ format\=\(string\)I420\,\ width\=\(int\)1920\,\
height\=\(int\)1080\,\ interlace-mode\=\(string\)progressive\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ chroma-site\=\(string\)mpeg2\,\
colorimetry\=\(string\)1:4:0:0\,\ framerate\=\(fraction\)30/1"
Redistribution de latence…
/GstPipeline:pipeline0/GstVideoRate:videorate0.GstPad:sink: caps =
"video/x-raw\,\ format\=\(string\)I420\,\ width\=\(int\)1920\,\
height\=\(int\)1080\,\ interlace-mode\=\(string\)progressive\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ chroma-site\=\(string\)mpeg2\,\
colorimetry\=\(string\)1:4:0:0\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstVideoConvert:videoconvert0.GstPad:sink: caps =
"video/x-raw\,\ format\=\(string\)I420\,\ width\=\(int\)1920\,\
height\=\(int\)1080\,\ interlace-mode\=\(string\)progressive\,\
pixel-aspect-ratio\=\(fraction\)1/1\,\ chroma-site\=\(string\)mpeg2\,\
colorimetry\=\(string\)1:4:0:0\,\ framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstX264Enc:x264enc0.GstPad:src: caps =
"video/x-h264\,\
codec_data\=\(buffer\)01640028ffe1001b67640028acd940780227e5c044000003000400000300f23c60c65801000568ebecb22c\,\
stream-format\=\(string\)avc\,\ alignment\=\(string\)au\,\
level\=\(string\)4\,\ profile\=\(string\)high\,\ width\=\(int\)1920\,\
height\=\(int\)1080\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\
framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:video_0: caps =
"video/x-h264\,\
codec_data\=\(buffer\)01640028ffe1001b67640028acd940780227e5c044000003000400000300f23c60c65801000568ebecb22c\,\
stream-format\=\(string\)avc\,\ alignment\=\(string\)au\,\
level\=\(string\)4\,\ profile\=\(string\)high\,\ width\=\(int\)1920\,\
height\=\(int\)1080\,\ pixel-aspect-ratio\=\(fraction\)1/1\,\
framerate\=\(fraction\)30/1"
/GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src: caps =
"video/quicktime\,\ variant\=\(string\)iso"
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps =
"video/quicktime\,\ variant\=\(string\)iso"
^Chandling interrupt.
Interruption : arrêt du pipeline…
EOS à la fermeture est activé -- EOS forcé sur le pipeline
Attente d’EOS.
/GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src: caps =
"video/quicktime\,\ variant\=\(string\)iso\,\ streamheader\=\(buffer\)\<\
00000cdc...\ \>"
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps =
"video/quicktime\,\ variant\=\(string\)iso\,\ streamheader\=\(buffer\)\<\
00000cdc...\ \>"
EOS reçu de l’élément « pipeline0 ».
EOS reçu - arrêt du pipeline…
Execution ended after 0:00:19.789246908
Définition du pipeline à PAUSED...
Définition du pipeline à READY (prêt)…
Définition du pipeline à NULL…
Libération du pipeline…

Informations about the webcam :

v4l2-ctl --all
Driver Info (not using libv4l2):
Driver name   : uvcvideo
Card type     : USB 2.0 Camera
Bus info      : usb-0000:00:1d.0-1.2
Driver version: 4.4.44
Capabilities  : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps   : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height      : 1920/1080
Pixel Format      : 'MJPG'
Field             : None
Bytes per Line    : 0
Size Image        : 4147789
Colorspace        : sRGB
Transfer Function : Default
YCbCr Encoding    : Default
Quantization      : Default
Flags             :
Crop Capability Video Capture:
Bounds      : Left 0, Top 0, Width 1920, Height 1080
Default     : Left 0, Top 0, Width 1920, Height 1080
Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 1920, Height 1080
Selection: crop_bounds, Left 0, Top 0, Width 1920, Height 1080
Streaming Parameters Video Capture:
Capabilities     : timeperframe
Frames per second: 30.000 (30/1)
Read buffers     : 0
                     brightness (int)    : min=-64 max=64 step=1 default=0
value=-64
                       contrast (int)    : min=0 max=64 step=1 default=32
value=64
                     saturation (int)    : min=0 max=128 step=1 default=60
value=128
                            hue (int)    : min=-40 max=40 step=1 default=0
value=-40
 white_balance_temperature_auto (bool)   : default=1 value=1
                          gamma (int)    : min=72 max=500 step=1
default=100 value=100
                           gain (int)    : min=0 max=100 step=1 default=0
value=100
           power_line_frequency (menu)   : min=0 max=2 default=1 value=1
      white_balance_temperature (int)    : min=2800 max=6500 step=1
default=4600 value=4600 flags=inactive
                      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
                  exposure_auto (menu)   : min=0 max=3 default=3 value=3
              exposure_absolute (int)    : min=1 max=5000 step=1
default=157 value=157 flags=inactive
         exposure_auto_priority (bool)   : default=0 value=1

I would appreciate any idea.
Thank you.

-- 
Damien Picard
Expert GWT
<http://www.editions-eni.fr/livres/gwt-google-web-toolkit-developpez-des-applications-internet-riches-ria-en-java/.97a1a26e7d5be94763fc45ac2a1e961a.html>
Mob : 06 11 51 47 78
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20170309/68caf003/attachment-0001.html>


More information about the gstreamer-devel mailing list