A basic command-line media player built with GStreamer that supports video and audio playback without a GUI.
- Play video and audio files
- Display playback position and duration
- Automatic format detection
- Error handling and status messages
- Support for seeking-enabled streams
Install GStreamer development packages:
- Download GStreamer from https://gstreamer.freedesktop.org/download/
- Install both runtime and development installers
- Add GStreamer bin directory to PATH
# Ubuntu/Debian
sudo apt-get install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
# Fedora
sudo dnf install gstreamer1-devel gstreamer1-plugins-base-develbrew install gstreamermkdir build
cd build
cmake ..
cmake --build .gcc main.c -o gst_player `pkg-config --cflags --libs gstreamer-1.0`cl main.c /I"C:\gstreamer\1.0\msvc_x86_64\include\gstreamer-1.0" /I"C:\gstreamer\1.0\msvc_x86_64\include\glib-2.0" /I"C:\gstreamer\1.0\msvc_x86_64\lib\glib-2.0\include" /link gstreamer-1.0.lib glib-2.0.lib gobject-2.0.lib# Using file path
./gst_player /path/to/video.mp4
# Using URI
./gst_player file:///path/to/video.mp4
# HTTP streaming
./gst_player http://example.com/video.mp4The player supports any format that GStreamer can decode, including:
- Video: MP4, AVI, MKV, MOV, WebM, FLV, etc.
- Audio: MP3, AAC, FLAC, OGG, WAV, etc.
- Streaming: HTTP, RTSP, etc.
- The player will automatically start playback
- Press Ctrl+C to stop playback
- Position and duration are displayed every second during playback
If you encounter errors:
- Ensure GStreamer is properly installed
- Check that the media file path is correct
- Verify the file format is supported
- Install additional GStreamer plugins if needed:
- gstreamer1.0-plugins-good
- gstreamer1.0-plugins-bad
- gstreamer1.0-plugins-ugly