Skip to content

Instantly share code, notes, and snippets.

@helloyanis
Last active May 25, 2026 17:51
Show Gist options
  • Select an option

  • Save helloyanis/e559b618e32e8801b3c8aceb0b745524 to your computer and use it in GitHub Desktop.

Select an option

Save helloyanis/e559b618e32e8801b3c8aceb0b745524 to your computer and use it in GitHub Desktop.
Namcam2 (Triforce camera) emulation on Dolphin

How to emulate the namcam2 on Dolphin emulator (Play Mariokart Arcade GP 1 & 2 with camera)

This tutorial will allow you to

  • Use your PC's camera in game
  • Use an image instead of the camera

You need

Preparing the environnement

  • Download the Namcam server file (at the end of this tutorial, there's a JavaScript file. Click Raw, then right click, save page as)
  • Make sure to place the file in an empty folder with nothing else besides it.
  • Open a terminal in this directory. The way you do this depends on your OS, but usually you can right click on an empty space inside of the folder to open it in the terminal
  • Type npm i express and press enter. This will install Express. If you get an error "Command not found", make sure node.js is correctly installed
  • ONLY if you want to use a static image instead of your webcam, follow these extra steps :
    • Add a .jpg image next to the .js file
    • Open the .js file in a code editor or notepad. Change USE_WEBCAM to false. Change STATIC_IMAGE_PATHto the name of your image
    • Save the file

Caution

The image or camera output must be 320px in width, and 240px in height, or else the game will crash when attempting to access it!

  • Type node namcam.js in the terminal and press enter. You will be given an URL, open it in the browser to test it and see if your image or camera appears.
  • In the Dolphin triforce settings, change the IP forward to match the URL given to you in the terminal. For example, if the URL you have is http://127.0.0.1:3000/img.jpg, set the namcam address to http://127.0.0.1:3000
  • Start the game and enable the service menu (map the SERVICE key in the Dolphin triforce settings)
  • In the game's test mode, go to "Camera test" and move the camera so that the face aligns with the frame
  • In the game's test mode, under "Game options" make sure the camera is enabled
  • You can now play! Enjoy!
const express = require('express');
const { exec } = require('child_process');
const fs = require('fs');
const path = require('path');
const app = express();
const PORT = 3000;
// CONFIG
const USE_WEBCAM = true; //Change this to false if you want to use an image
const STATIC_IMAGE_PATH = 'image.jpg'; //If you want to use an image, place it next to this file and input the name 'in between the quotes'
//IMAGE FORMAT MUST BE 320px WIDTH AND 240px HEIGHT!! Or else the game will crash
const TEMP_IMAGE = path.join(__dirname, 'webcam.jpg');
app.get('/img.jpg', (req, res) => {
if (USE_WEBCAM) {
console.log('Capturing webcam image...');
captureWebcam((err) => {
if (err) {
return res.status(500).send(err.message);
}
fs.readFile(TEMP_IMAGE, (err, data) => {
if (err) {
return res.status(500).send('Read failed');
}
res.set({
'Content-Type': 'image/jpeg',
'Content-Length': data.length,
'Connection': 'close'
});
res.end(data);
});
});
} else {
console.log('Serving static image...');
const data = fs.readFileSync(STATIC_IMAGE_PATH);
res.set({
'Content-Type': 'image/jpeg',
'Content-Length': data.length,
'Connection': 'close'
});
res.end(data);
}
});
let capturing = false;
function captureWebcam(callback) {
if (capturing) return callback(new Error('Busy'));
capturing = true;
const command = `ffmpeg -y -nostdin -loglevel error -f video4linux2 -i /dev/video0 -frames:v 1 -q:v 2 ${TEMP_IMAGE}`; //Replace this with a command that allows you to take a picture if this doesn't work for your OS
exec(command, { timeout: 10000 }, (error) => {
capturing = false;
if (error) {
return callback(error);
}
fs.access(TEMP_IMAGE, fs.constants.R_OK, (accessErr) => {
callback(accessErr || null);
});
});
}
app.listen(PORT, '127.0.0.1', () => {
console.log(`Server running at http://127.0.0.1:${PORT}/img.jpg`);
});
@t6productions

Copy link
Copy Markdown

For Windows Users:
Replace

ffmpeg -y -nostdin -loglevel error -f video4linux2 -i /dev/video0 -frames:v 1 -q:v 2 ${TEMP_IMAGE}

With

ffmpeg -y -nostdin -loglevel error -f dshow -i video="[Your Camera's Name]" -frames:v 1 -q:v 2 ${TEMP_IMAGE}

@t6productions

Copy link
Copy Markdown

Still doesn't work in the actual game though

@helloyanis

Copy link
Copy Markdown
Author

Still doesn't work in the actual game though

It must be an issue with Dolphin on Windows, as it works fine on Linux with this setup

image-1

Maybe open an issue or something?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment