PBWebcam - cross-platform camera access!
PBWebcam - cross-platform camera access!
SDL 3 officially released in January, and since then I've been working on wrapping its cross-platform webcam/camera functionality into a single easy-to-use PureBasic includefile!
There were some camera bugfixes and improvements in SDL 3.2.6 released a few days ago, so now I'm ready to share version 1.0 of my code. Testers and feedback welcome! I've been testing it on both Windows and Linux. Should work on Mac too.
PBWebcam project on GitHub
https://github.com/kenmo-pb/PBWebcam
See the front page README and its links. You need three things:
1. Get my SDL3.pbi
2. Get my PBWebcam.pbi - I recommend you just download or clone the repo
3. Get SDL3 for your OS... this is a DLL on Windows, a .so on Linux, etc. You don't need the "devel" package.
Then run "Demo" which lets you choose between your cameras and specs, or "SimplerDemo" to immediately get a webcam view with no configuration. You can have a live webcam in a CanvasGadget in just a few lines of added code!
More about SDL / SDL3... it's great!
https://libsdl.org/
https://github.com/libsdl-org/SDL
There were some camera bugfixes and improvements in SDL 3.2.6 released a few days ago, so now I'm ready to share version 1.0 of my code. Testers and feedback welcome! I've been testing it on both Windows and Linux. Should work on Mac too.
PBWebcam project on GitHub
https://github.com/kenmo-pb/PBWebcam
See the front page README and its links. You need three things:
1. Get my SDL3.pbi
2. Get my PBWebcam.pbi - I recommend you just download or clone the repo
3. Get SDL3 for your OS... this is a DLL on Windows, a .so on Linux, etc. You don't need the "devel" package.
Then run "Demo" which lets you choose between your cameras and specs, or "SimplerDemo" to immediately get a webcam view with no configuration. You can have a live webcam in a CanvasGadget in just a few lines of added code!
More about SDL / SDL3... it's great!
https://libsdl.org/
https://github.com/libsdl-org/SDL
Re: PBWebcam - cross-platform camera access!
good to have a cross platform solution. thanks
Re: PBWebcam - cross-platform camera access!
Very cool, thanks for sharing! I love SDL 

Re: PBWebcam - cross-platform camera access!
Thanks for sharing this with us Kenmo
I've been using Escapi for a while, but its inability to enumerate available resolutions & video formats was causing problems for me.

I've been using Escapi for a while, but its inability to enumerate available resolutions & video formats was causing problems for me.
Re: PBWebcam - cross-platform camera access!
Hello, work fantastic here PB6.21 beta6, x86 and x64 over windows 10 and 11. I will try in macOS and linux (ubuntu) soon
Is nice can count with a multiOS solution integrated in PB for webcam.
Very nice work and many thanks for share Kenmo.

Is nice can count with a multiOS solution integrated in PB for webcam.
Very nice work and many thanks for share Kenmo.
If translation=Error: reply="Sorry, Im Spanish": Endif
-
- Enthusiast
- Posts: 141
- Joined: Sat Sep 21, 2019 4:24 pm
Re: PBWebcam - cross-platform camera access!
Nice work kenmo! Thanks for sharing.
You can check my games at:
https://ricardo-sdl.itch.io/
https://ricardo-sdl.itch.io/
- captain_skank
- Enthusiast
- Posts: 639
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: PBWebcam - cross-platform camera access!
Hi,
Just came across your code as i need to capture a webcam image.
Downloaded all required code, but every time i run the demo i get :
'Could not examine webcams, or none found!'
It's odd becasue i can see the live images from my 2 webcams using the built in windows 11 camera app.
Anybody got any ideas what this could be ?
FYI : i'm running Windows 11 Pro, PureBasic 6.21 (Windows - x64), the latest SDL3.dll and SDL3.pbi
cheers
Just came across your code as i need to capture a webcam image.
Downloaded all required code, but every time i run the demo i get :
'Could not examine webcams, or none found!'
It's odd becasue i can see the live images from my 2 webcams using the built in windows 11 camera app.
Anybody got any ideas what this could be ?
FYI : i'm running Windows 11 Pro, PureBasic 6.21 (Windows - x64), the latest SDL3.dll and SDL3.pbi
cheers
Re: PBWebcam - cross-platform camera access!
Hi captain_skank,
I have the same configuration: Windows 11 Pro, PureBasic 6.21 (Windows - x64)
You may already have done some or all of the following, but it worked for me OOTB.
1. Download: https://github.com/kenmo-pb/SDLx/archiv ... s/main.zip
• Main SDL2/SDL3 wrapper for PureBasic
2. Download: https://github.com/kenmo-pb/PBWebcam/ar ... s/main.zip
• Demo PBWebcam examples
3. Download: https://github.com/libsdl-org/SDL/relea ... 32-x64.zip
• SDL 3.2.16 Assets (this is the one that worked for me)
4. Extract all three downloads to separate folders.
You now have two options to test your webcam:
1. Copy SDL3.dll to \SDLx-main\examples\
2. Execute \SDLx-main\examples\SDL3_Camera.pb
• This is probably the better option as it includes CTRL + S to save a webcam frame.
Or
1. Copy SDL3.dll to \PBWebcam-main\
2. Copy SDL3.pbi to \PBWebcam-main\
3. Execute \PBWebcam-main\PBWebcam_Demo.pb
4. Execute \PBWebcam-main\PBWebcam_SimplerDemo.pb
I have the same configuration: Windows 11 Pro, PureBasic 6.21 (Windows - x64)
You may already have done some or all of the following, but it worked for me OOTB.
1. Download: https://github.com/kenmo-pb/SDLx/archiv ... s/main.zip
• Main SDL2/SDL3 wrapper for PureBasic
2. Download: https://github.com/kenmo-pb/PBWebcam/ar ... s/main.zip
• Demo PBWebcam examples
3. Download: https://github.com/libsdl-org/SDL/relea ... 32-x64.zip
• SDL 3.2.16 Assets (this is the one that worked for me)
4. Extract all three downloads to separate folders.
You now have two options to test your webcam:
1. Copy SDL3.dll to \SDLx-main\examples\
2. Execute \SDLx-main\examples\SDL3_Camera.pb
• This is probably the better option as it includes CTRL + S to save a webcam frame.
Or
1. Copy SDL3.dll to \PBWebcam-main\
2. Copy SDL3.pbi to \PBWebcam-main\
3. Execute \PBWebcam-main\PBWebcam_Demo.pb
4. Execute \PBWebcam-main\PBWebcam_SimplerDemo.pb
Last edited by JHPJHP on Thu Jul 24, 2025 6:20 pm, edited 1 time in total.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
- captain_skank
- Enthusiast
- Posts: 639
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: PBWebcam - cross-platform camera access!
Thanks very much JHPJHP, just goes to show it's who you know not what you know 
Works perfectly now.

Works perfectly now.
-
- Enthusiast
- Posts: 160
- Joined: Wed May 20, 2020 5:19 pm
- Location: The 3rd planet in the Solar System
- Contact:
Re: PBWebcam - cross-platform camera access!
Here works with PC web camera GOOD.
Thank U!
Possible to use with other cameras?
A have analog camera connected through USB capture device.
Camera is recognised by your VfW Camera program, but this program sometimes caused BSOD
Best Wishes.
Thank U!
Possible to use with other cameras?
A have analog camera connected through USB capture device.
Camera is recognised by your VfW Camera program, but this program sometimes caused BSOD
Best Wishes.
Mac Studio M1Max, PB 6.12 Arm64 and x64.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.
Re: PBWebcam - cross-platform camera access!
Hi dibor,
Inside the code \SDLx-main\examples\SDL3_Camera.pb (lines 29 to 46) you can check if your camera is recognized.
• If it is recognized set the associated index:
Note: If relevant, I made some minor changes to my (outdated) VfW Capture script.
Inside the code \SDLx-main\examples\SDL3_Camera.pb (lines 29 to 46) you can check if your camera is recognized.
• If it is recognized set the associated index:
Code: Select all
firstID.SDL_CameraID = *devices\id[0]
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
-
- Enthusiast
- Posts: 160
- Joined: Wed May 20, 2020 5:19 pm
- Location: The 3rd planet in the Solar System
- Contact:
Re: PBWebcam - cross-platform camera access!
Thank U JHPJHP
I will try.
Can U do VfW window resizable?
I will try.
Can U do VfW window resizable?
Mac Studio M1Max, PB 6.12 Arm64 and x64.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.
Re: PBWebcam - cross-platform camera access!
Hi dibor,
I've updated my VfW example, but you should really try to get kenmo's cross-platform PBWebcam working.
• While the window is resizable the resolution is static; the VfW capture screen is just being stretched.
Not wanting to side-track this thread anymore then we already have, please post any future VfW questions to my PM.
I've updated my VfW example, but you should really try to get kenmo's cross-platform PBWebcam working.
• While the window is resizable the resolution is static; the VfW capture screen is just being stretched.
Not wanting to side-track this thread anymore then we already have, please post any future VfW questions to my PM.
If you're not investing in yourself, you're falling behind.
My PureBasic Stuff ➤ FREE STUFF, Scripts & Programs.
My PureBasic Forum ➤ Questions, Requests & Comments.
-
- Enthusiast
- Posts: 160
- Joined: Wed May 20, 2020 5:19 pm
- Location: The 3rd planet in the Solar System
- Contact:
Re: PBWebcam - cross-platform camera access!
I can not to run PBWebcam example under MacOS 
Lib., do not find
Have put all folders to the right place, as shown in the install.md file and set right path in the source.
Looks like I did something wrong

Lib., do not find

Have put all folders to the right place, as shown in the install.md file and set right path in the source.
Looks like I did something wrong

Mac Studio M1Max, PB 6.12 Arm64 and x64.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.
Macbook Air M2, PB 6.12 Arm64 and x64.
Windows 10, PB 6.12 x64 and x86.
Re: PBWebcam - cross-platform camera access!
This is fantastic! Thanks for doing all that work!