Hi all,
运行环境:ubuntu22.04LTS,VMware 16 pro
安装gstreamer:
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-libav gstreamer1.0-doc gstreamer1.0-tools gstreamer1.0-x gstreamer1.0-alsa gstreamer1.0-gl gstreamer1.0-gtk3 gstreamer1.0-qt5 gstreamer1.0-pulseaudio
However I found that gstreamer1.0-doc is not included, so I skipped this and haven't met errors. If anyone find errors or some other situations feel free to contact me.
open terminal, remember to add remove device webcam when using v4l2src.
1.测试视频:
gst-launch-1.0 videotestsrc! videoconvert ! autovideosink
gst-launch-1.0 videotestsrc! videoconvert ! xvimagesink
gst-launch-1.0 videotestsrc! videoconvert ! waylandsink
remember that xvimagesink/ximagesink run on x11 server, and waylandsink run on wayland/weston. The way to change ubuntu 22.04 from x11 to wayland:
https://linuxconfig.org/how-to-enable-disable-wayland-on-ubuntu-22-04-desktop
2.测试webcam:
gst-launch-1.0 v4l2src ! videoconvert ! autovideosink
gst-launch-1.0 v4l2src ! videoconvert ! xvimagesink
gst-launch-1.0 v4l2src ! videoconvert ! waylandsink
3. change resolution:
gst-launch-1.0 v4l2src ! videoscale ! video/x-raw,width=1280,height=720,framerate=30/1 ! videoconvert ! xvimagesink
4: h264 decode
gst-launch-1.0 v4l2src ! video/x-h264-raw ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink
5: record
gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=30 ! videoconvert ! 'video/x-raw, width=640, height=480, framerate=30/1' ! x264enc ! mp4mux ! filesink sync=false location=camera-h264-640x480.mp4
num-buffers means the pipeline will only run 30 frames, and break out immediately. In another way, this example set the video in 30 fps, so the record video will only last 30/30=1 second. If you wish to quit before dealine, type ctrl^c in terminal.
That's the end of today's sharing
2022/11/21