<div dir="ltr">Hi,<div><br></div><div>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.</div><div><br></div><div>I am able to achieve it using this command :</div><div><br></div><div>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</div><div><br></div><div>It does the job but the resulting videotestsrc.mp4 does not seem to have the right framerate because the video is "accelerated".</div><div>I think it could be caused by two things :</div><div> - 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 ?</div><div> - 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.</div><div><br></div><div>Some tests I do :</div><div> - decrease the frame size : leads to the same result</div><div>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</div><div> - record with mjpeg-streamer : works fine, the avi is played at 30 fps, not accelerated (the AVI is definitively too large in MJPEG)</div><div>./mjpg_streamer -i 'input_uvc.so -r 1920x1080' -o 'output_file.so -f /home/dams -m video.avi'</div><div><br></div><div><br></div><div>The debug output, in 1920x1080 :</div><div><br></div><div><div>Définition du pipeline à PAUSED...</div><div>Le pipeline est actif et n’a pas besoin de phase PREROLL…</div><div>Passage du pipeline à la phase PLAYING…</div><div>New clock: GstSystemClock</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/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"</div><div>Redistribution de latence…</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/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"</div><div>/GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src: caps = "video/quicktime\,\ variant\=\(string\)iso"</div><div>/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = "video/quicktime\,\ variant\=\(string\)iso"</div><div>^Chandling interrupt.</div><div>Interruption : arrêt du pipeline…</div><div>EOS à la fermeture est activé -- EOS forcé sur le pipeline</div><div>Attente d’EOS.</div><div>/GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src: caps = "video/quicktime\,\ variant\=\(string\)iso\,\ streamheader\=\(buffer\)\<\ 00000cdc...\ \>"</div><div>/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = "video/quicktime\,\ variant\=\(string\)iso\,\ streamheader\=\(buffer\)\<\ 00000cdc...\ \>"</div><div>EOS reçu de l’élément « pipeline0 ».</div><div>EOS reçu - arrêt du pipeline…</div><div>Execution ended after 0:00:19.789246908</div><div>Définition du pipeline à PAUSED...</div><div>Définition du pipeline à READY (prêt)…</div><div>Définition du pipeline à NULL…</div><div>Libération du pipeline…</div><div><br></div><div>Informations about the webcam :</div><div><br></div><div><div>v4l2-ctl --all</div><div>Driver Info (not using libv4l2):</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">     </span>Driver name   : uvcvideo</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>Card type     : USB 2.0 Camera</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>Bus info      : usb-0000:00:1d.0-1.2</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>Driver version: 4.4.44</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Capabilities  : 0x84200001</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>Video Capture</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">          </span>Streaming</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>Extended Pix Format</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>Device Capabilities</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>Device Caps   : 0x04200001</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">            </span>Video Capture</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">          </span>Streaming</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>Extended Pix Format</div><div>Priority: 2</div><div>Video input : 0 (Camera 1: ok)</div><div>Format Video Capture:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Width/Height      : 1920/1080</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>Pixel Format      : 'MJPG'</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>Field             : None</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Bytes per Line    : 0</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>Size Image        : 4147789</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>Colorspace        : sRGB</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">   </span>Transfer Function : Default</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">    </span>YCbCr Encoding    : Default</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>Quantization      : Default</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Flags             : </div><div>Crop Capability Video Capture:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>Bounds      : Left 0, Top 0, Width 1920, Height 1080</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>Default     : Left 0, Top 0, Width 1920, Height 1080</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Pixel Aspect: 1/1</div><div>Selection: crop_default, Left 0, Top 0, Width 1920, Height 1080</div><div>Selection: crop_bounds, Left 0, Top 0, Width 1920, Height 1080</div><div>Streaming Parameters Video Capture:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>Capabilities     : timeperframe</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">      </span>Frames per second: 30.000 (30/1)</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>Read buffers     : 0</div><div>                     brightness (int)    : min=-64 max=64 step=1 default=0 value=-64</div><div>                       contrast (int)    : min=0 max=64 step=1 default=32 value=64</div><div>                     saturation (int)    : min=0 max=128 step=1 default=60 value=128</div><div>                            hue (int)    : min=-40 max=40 step=1 default=0 value=-40</div><div> white_balance_temperature_auto (bool)   : default=1 value=1</div><div>                          gamma (int)    : min=72 max=500 step=1 default=100 value=100</div><div>                           gain (int)    : min=0 max=100 step=1 default=0 value=100</div><div>           power_line_frequency (menu)   : min=0 max=2 default=1 value=1</div><div>      white_balance_temperature (int)    : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive</div><div>                      sharpness (int)    : min=0 max=6 step=1 default=2 value=2</div><div>         backlight_compensation (int)    : min=0 max=2 step=1 default=1 value=1</div><div>                  exposure_auto (menu)   : min=0 max=3 default=3 value=3</div><div>              exposure_absolute (int)    : min=1 max=5000 step=1 default=157 value=157 flags=inactive</div><div>         exposure_auto_priority (bool)   : default=0 value=1</div></div><div><br></div><div>I would appreciate any idea.</div><div>Thank you.</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Damien Picard<br><a href="http://www.editions-eni.fr/livres/gwt-google-web-toolkit-developpez-des-applications-internet-riches-ria-en-java/.97a1a26e7d5be94763fc45ac2a1e961a.html" target="_blank">Expert GWT</a><br>Mob : 06 11 51 47 78</div></div>
</div></div>