GNOME Bugzilla – Bug 796478
avfvideosrc Consuming Too much CPU
Last modified: 2018-11-03 14:24:53 UTC
Compare to videotestsrc, avfvideosrc taking too much CPU. pipeline with videotestsrc CPU use : ~ 28.2% pipeline with avfvideosrc CPU use : ~ 207.2% Following are terminal log for reference: ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps PID TTY TIME CMD 1111 ttys000 0:00.49 -bash 12116 ttys000 0:20.14 ./objs/srs -c ./conf/srs.conf 12196 ttys000 0:00.06 tail -f objs/srs.log 14198 ttys002 0:00.46 -bash 22944 ttys002 0:03.17 gst-launch-1.0 videotestsrc is-live=true ! videoconvert ! x264enc tune=zerolatency ! video/x-h264 ! mpegtsmux name=mux ! queu 22733 ttys003 0:00.15 -bash ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps -p 22944 -o %cpu,%mem %CPU %MEM 25.6 0.4 ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps -p 22944 -o %cpu,%mem %CPU %MEM 28.2 0.4 ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps -p 22944 -o %cpu,%mem %CPU %MEM 28.5 0.4 ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps PID TTY TIME CMD 1111 ttys000 0:00.49 -bash 12116 ttys000 0:20.15 ./objs/srs -c ./conf/srs.conf 12196 ttys000 0:00.06 tail -f objs/srs.log 14198 ttys002 0:00.47 -bash 22951 ttys002 0:11.46 gst-launch-1.0 avfvideosrc ! videoconvert ! x264enc tune=zerolatency ! video/x-h264 ! mpegtsmux name=mux ! queue ! udpsink ho 22733 ttys003 0:00.17 -bash ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps -p 22951 -o %cpu,%mem %CPU %MEM 211.1 0.7 ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps -p 22951 -o %cpu,%mem %CPU %MEM 207.2 0.7 ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ gst-inspect-1.0 --version gst-inspect-1.0 version 1.14.0 GStreamer 1.14.0
Thanks for the report! Unfortunately, it seems that you're not testing with the exact same frame sizes which can impact the CPu performance. E.g. videotestsrc will by default choose a frame size of 320x240. avfvideosrc most likely chose the highest frame size supported by your camera/screen which may be 720p or higher. Also, have you performed some profiling results that would point to a specific place to look into for these performance issues?
Still The CPU use is up by 75%. Similar issue is also in iOS as with avfvideosrc increase CPU use by 75%, with video resolution 240*320. Logs: ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps PID TTY TIME CMD 1111 ttys000 0:00.49 -bash 12116 ttys000 0:22.79 ./objs/srs -c ./conf/srs.conf 12196 ttys000 0:00.06 tail -f objs/srs.log 14198 ttys002 0:01.04 -bash 23531 ttys002 0:12.14 gst-launch-1.0 avfvideosrc ! video/x-raw,width=640,height=480 ! videoconvert ! x264enc tune=zerolatency ! video/x-h264 ! mpegtsmux name=mux ! queue ! udpsink host=127.0.0.1 port= 22733 ttys003 0:00.25 -bash ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps -p 23531 -o %cpu,%mem %CPU %MEM 131.9 0.5 ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps -p 23531 -o %cpu,%mem %CPU %MEM 126.9 0.5 ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps PID TTY TIME CMD 1111 ttys000 0:00.49 -bash 12116 ttys000 0:23.16 ./objs/srs -c ./conf/srs.conf 12196 ttys000 0:00.07 tail -f objs/srs.log 14198 ttys002 0:01.16 -bash 23704 ttys002 0:02.25 gst-launch-1.0 videotestsrc ! video/x-raw,width=640,height=480 ! videoconvert ! x264enc tune=zerolatency ! video/x-h264 ! mpegtsmux name=mux ! queue ! udpsink host=127.0.0.1 port 22733 ttys003 0:00.26 -bash ADFGTECHs-MacBook-Pro-2:iOSGstreamerClient prafullasingh$ ps -p 23704 -o %cpu,%mem %CPU %MEM 46.8 0.4
Can you compare with cpu usage for gst-launch-1.0 avfvideosrc ! fakesink -v ?
ADFGTECHs-MacBook-Pro-2:~ prafullasingh$ ps PID TTY TIME CMD 11007 ttys001 0:00.02 -bash 11013 ttys001 0:05.78 gst-launch-1.0 avfvideosrc ! fakesink -v 11016 ttys002 0:00.02 -bash 10691 ttys003 0:00.04 -bash 10992 ttys003 0:14.12 ffplay rtmp://192.168.11.210/live/livestream2 ADFGTECHs-MacBook-Pro-2:~ prafullasingh$ ps -p 11013 -o %cpu,%mem %CPU %MEM 12.2 0.5 Above are the result you were seeking. Apologies for the delay. Also, I am able to reduce CPU use to ~50% if I use Appsrc and push camera images with 20 fps.
-- GitLab Migration Automatic Message -- This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/724.