0

I have a C920 logitec usb webcam installed on an odroid xu4, with linux ubuntu installed. I want to record video at the highest quality in h264 format.

So 30 frames per seconds and 1920x1080 video size. While at the same time send a stream h264 format but on a lower quality.

I can record and stream at the same quality but not with different quality. Does anybody now how to fix the pipeline such that I can stream at lower quality ? Working (same resolution):


gst-launch-1.0 v4l2src device=/dev/video0 ! tee name=t \
! queue  ! video/x-h264,framerate=30/1,width=1920,height=1080 ! h264parse ! mp4mux ! filesink location=/media/webcam.mp4 -v -e t. \
! queue ! h264parse ! rtph264pay ! udpsink host=113.141.0.1 port=4321

Not working: (sending size 800x600):

gst-launch-1.0 v4l2src device=/dev/video0 ! tee name=t \
! queue  ! video/x-h264,framerate=30/1,width=1920,height=1080 ! h264parse ! mp4mux ! filesink location=/media/webcam.mp4 -v -e t. \
! queue ! video/x-h264,framerate=30/1,width=800,height=600 ! h264parse ! rtph264pay ! udpsink host=113.141.0.1 port=4321

here is the error i get when trying different resolutions :



ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2865): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming task paused, reason not-negotiated (-4)
/GstPipeline:pipeline0/GstMP4Mux:mp4mux0.GstPad:src: caps = video/quicktime, variant=(string)iso
EOS on shutdown enabled -- waiting for EOS after Error
Waiting for EOS...
/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/quicktime, variant=(string)iso
ERROR: from element /GstPipeline:pipeline0/GstH264Parse:h264parse1: No valid frames found before end of stream
Additional debug info:
gstbaseparse.c(1153): gst_base_parse_sink_event_default (): /GstPipeline:pipeline0/GstH264Parse:h264parse1
ERROR: from element /GstPipeline:pipeline0/GstH264Parse:h264parse0: No valid frames found before end of stream
Additional debug info:
gstbaseparse.c(1153): gst_base_parse_sink_event_default (): /GstPipeline:pipeline0/GstH264Parse:h264parse0
Maxence
  • 11
  • 2

1 Answers1

0

I found a possible solution, but it is a really heavy operation (CPU wise) as we first need to decode the H264 video from the webcam, change the resolution and encode it again.

Depending on the framerate, videoscale, encoding speed and bitrate this operation can take up to multiple cores on the odroid-xu4. Compared to not changing the resolution at all, where maximum 20% of one core at the highest resolution and framerate of the H264 setting on the webcam (1920x1080 @30fps).


gst-launch-1.0 v4l2src device=/dev/video0 ! tee name=t ! queue  ! video/x-h264,framerate=30/1,width=1920,height=1080 ! h264parse ! mp4mux ! filesink location=/root/temp/webcam.mp4 -v -e t. ! queue ! decodebin ! videoscale ! videorate ! video/x-raw,framerate=30/1,width=800,height=600 ! x264enc bitrate=500 speed-preset=superfast tune=zerolatency ! h264parse ! rtph264pay ! udpsink host=132.132.10.11 port=1234 -v

Note that if x264enc does not have the setting 'tune=zerolatency' the pipeline will get stuck with the message 'Redistribute latency...'

Does anybody knows a similar command but with less CPU usage ?

Maxence
  • 11
  • 2
  • If your system does have H.264 encoder hardware you may be able to use via the VAAPI or OpenMAX plugins for video encoding. You will have to do some research here. If not, you will have to do it in software which is - as you have already noticed quite expensive. – Florian Zwoch Apr 01 '17 at 08:02