这是一个清洁、用户友好的 raylib 扩展,通过 FFmpeg libav* 库提供了无缝的音频和视频流支持。它可让您轻松集成
这是一个清洁、用户友好的 raylib 扩展,通过 FFmpeg libav* 库提供了无缝的音频和视频流支持。它可让您轻松集成
Note: This library is in beta. Your feedback and support in enhancing its quality are greatly appreciated!
raylib-media is a clean and user-friendly extension for raylib that adds seamless audio and video streaming support via the FFmpeg libav* libraries. It enables easy integration of multimedia content into raylib applications, providing direct access to video textures and audio streams, with support for seeking and looping.
Texture and AudioStream for efficient media handlingLoadMedia function.These 3-4 lines of code show the minimal code needed to play a video with raylib-media:
#include
MediaStream media = LoadMedia("path/to/your_file.mp4"); // Load the media
while (...) { // Begin your main loop
...
UpdateMedia(&media); // Update the media stream according to frame time
...
DrawTexture(media.videoTexture, 0, 0, WHITE); // Draw the video frame
...
}
UnloadMedia(&media); // Unload media when doneDescription: Demonstrates how to play a video on the screen and loop it continuously.
Description: A simple media player illustrating how to control playback speed, seek, pause, loop, adjust audio volume, and apply real-time shader effects to the video.
Description: A 3D demo scene demonstrating multiple video streams with synchronized audio that dynamically adjusts based on cursor proximity.
Description: Demonstrates how to use
LoadMediaFromStreamwith custom callbacks for reading media.
This example simulates a custom stream using a memory buffer, showcasing the flexibility of the API. Real-world use cases include:
- Reading from compressed archives
- Streaming over a network
- Accessing custom data formats or encrypted resources
raylib-media depends on the following files and libraries:
E.g. with GCC:
gcc ... rmedia.c -lraylib -lavcodec -lavformat -lavutil -lswresample -lswscale
src/raymedia.h and src/rmedia.c
rmedia.c and use the compiled library.The following subset of libav* libraries from FFmpeg:
libavcodeclibavformatlibavutillibswresamplelibswscaleYou may want to start by using precompiled libraries and later compile your own version, if needed:
Linux: Install via your package manager (e.g., sudo apt install libavcodec-dev libavformat-dev libavutil-dev libswresample-dev libswscale-dev).
macOS:
Use Homebrew (brew install ffmpeg).
Windows:
Download compiled libraries from sources like FFmpeg Builds by BtbN: ffmpeg-n7.1-latest-win64-lgpl-shared-7.1.zip
FFmpeg is available in two versions:
What does this mean for you?
This project is licensed under the Zlib License - see the LICENSE file for details.
Special thanks to the following resources:
暂无开放 Issues,或尚未同步最近议题。