GStreamer Workshop Part 1: Displaying Camera Video in Real Time

This article is a translated version of my original post on Qiita. Original (Japanese): https://qiita.com/segur/items/2585dbf5a51ce7acec3b

GStreamer Workshop Part 1: Displaying Camera Video in Real Time

Hello! This article is the first in the "GStreamer Workshop" series.

In this first session, we'll display video from a camera connected to your PC.

Installation Steps

Install GStreamer using the following commands.

# For macOS
brew install gstreamer gst-plugins-base gst-plugins-good
# For Windows
choco install gstreamer --package-parameters="'/Full'" -y

After installation is complete, restart your terminal.

Displaying Camera Video

You can display camera video in a window in real time with the following commands!

# For macOS
gst-launch-1.0 avfvideosrc ! videoconvert ! queue ! autovideosink
# For Windows
gst-launch-1.0 mfvideosrc ! videoconvert ! queue ! autovideosink

Solutions If the Camera Does Not Display

Explanation of Elements Used

In GStreamer, small processing units called elements are connected in a pipeline.

Element Windows macOS Role
mfvideosrc Camera input (source). Uses Windows Media Foundation to capture video from the camera.
avfvideosrc Camera input (source). Uses macOS AVFoundation to capture video from the camera.
videoconvert Video format conversion. Formats output for the next element (e.g., pixel format).
queue Asynchronous buffer. Decouples processing between elements for smooth video display.
autovideosink Video display. Automatically selects the optimal rendering backend for your OS to display video on the screen.

Meaning of !

The ! is an operator connecting elements. It means "send the output of this element to the input of the next element."

A ! B ! C

This indicates processing in the order of "A → B → C".

Conclusion

Next time, we'll explain how to use GStreamer to stream camera video in real time over RTSP!

https://qiita.com/segur/items/e88a293cf9dc49ed08ec