Python Virtual Motion-JPEG Camera Simulation System for Cyber Exercise
Project Design Purpose : This project is designed to create a lightweight, extensible camera-simulation service program that exposes a Motion-JPEG (MJPEG) video stream over HTTP(s) via a Flask web interface for using in the cyber ranges, red/blue exercises, and research where realistic camera endpoints are required without physical hardware.
The simulated video stream can be generated from five different type of source:
The simulator intentionally mimics the web UI and behavior of Axis IP cameras so it can also be deployed as a believable camera honeypot or as a drop-in replacement for testing and integration.
# Author: Yuancheng Liu
# Created: 2025/10/15
# version: v_0.0.5
# Copyright: Copyright (c) 2025 LiuYuancheng
# License: GNU General Public License V3
Introduction
The IoT/IP cameras are one of the critical sensors in modern IT/OT systems— used for surveillance, safety monitoring, and operational visibility. In digital-twin and simulation environments (where MU, PLCs, RTUs and even physical-world entities like trains or runway lights are modeled in software), realistic camera endpoints are often missing. The Python Virtual Motion-JPEG Camera Simulator is designed for filling that gap by producing believable MJPEG camera streams that can be integrated into the digital twins, cyber ranges, monitoring dashboards, and deception/honeypot deployments.
This project provides a lightweight, portable simulator that can run in VMs or containers and expose MJPEG streams over HTTP(s) with an Axis-style web UI. The system workflow diagram is shown below:
The video streams can be generated by live devices, prerecorded datasets, or on-host captures so the simulator can present contextually appropriate video — for example, showing a landing aircraft on a simulated runway camera when the digital twin indicates a plane is on final approach.
Architecture Overview
The system contents three main components as shown in the below architecture diagram:
System Design
This section introduces the detailed design and internal structure of the three major components of the system introduced in the Introduction[Architecture Overview] section.
Design of Virtual Camera Client Library
The Virtual Camera Client Library is responsible for transforming various video sources into continuous MJPEG streams that can be served to browsers or other applications. The core of this module is the base class camClient, which defines the streaming pipeline consisting of five main steps:
Step 1: Frame Capture from Source
Step 2: Image JPEG Encoding
_, buffer = cv2.imencode('.jpg', frame)
Step 3: Return HTTP Streaming
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + buffer.tobytes() + b'\r\n')
Step 4: Multipart MJPEG Response
mimetype='multipart/x-mixed-replace; boundary=frame'
Step 5: Browser Renders Live Stream
<img src="{{ url_for('video_feed') }}" width="900" height="500">
Class Structure and Source Inheritance
The camClient base class is extended by several specialized subclasses that handle different input sources:
Each subclass manages its own capture logic while maintaining a unified streaming interface for the Flask server and dashboards.
Design of Flask Camera Server
The Flask Camera Server is a web host providing user interfaces, video live view, configuration options, and API endpoints for video streaming. It also supports secure access control and linkage with physical-world simulation data in cyber range or digital twin environments. The Flask server’s operational flow / structure is shown below:
The four modules function detail includes:
The Flask-based web server provides four main pages for users as shown below :
[1] Camera Home Page
The default landing page when the user access the camera simulator IP address, prompting user login with valid credentials before accessing the camera system :
Recommended by LinkedIn
[2] Camera Video Live View Page
After the user login with the correct credentials, they can access the pages displays the current live MJPEG stream. Users can adjust frame resolution and FPS in real time from the page:
[3] User Configuration Page
Allows different types of user to manage and change the access credential. The current version provides 2 type of users:
[4] Access Token Configuration Page
Used for generating and managing MJPEG API access tokens for external applications. For other program which use the motion-JPEG API to fetch the frame, a valid access token is required when calling the API url. Only the admin user can access the API token configuration page as shown below:
There are 2 types of API access tokens:
The user access rule and available function are shown in the below table:
Design of Multi-Camera View Monitor Dashboard
The Multi-Camera View Monitor Dashboard aggregates multiple virtual camera streams into one unified monitoring interface. It fetches MJPEG video feeds through HTTP API calls and displays them in a configurable multi-view layout. The network topology and configuration of the camera simulators and the dashboard is shown below:
The display dashboard feature includes:
Dashboard's Camera Access Configuration File
Each camera feed is defined in a JSON configuration file. Below is an example to add a new camera into the dashboard:
"Desktop1": {
"name": "Desktop screenshot 1 virtual Camera",
"url": "http://127.0.0.1:5000/cgi-bin/mjpg/",
"token": "motionJPEG",
"size": [
640,
480
]
},
The dashboard supports flexible layout configuration, adjustable FPS, and can display multiple camera streams in a single window or across multiple displays.
System Configuration and Usage
For system usage and configuration, please refer to the System Usage Manual Document : https://github.com/LiuYuancheng/Python_Virtual_MotionJPEG_Camera/blob/main/UsageManual.md
Development Environment : Python 3.7.4+
Project file list and module function description
Virtual Camera Client Library
Flask Camera Server
Multi-Camera View Monitor Dashboard
Program Typical Use Cases
The system is design for using in build the OT cyber ranges and supporting the cyber exercise, the possible use cases include:
We will also show two use cases of how this project is used to simulate 4 different cameras in the aviation runway cyber range and monitor the railway cyber range HMI(s) in cyber exercise.
Usage Case as Cyber Range Surveillance System
The system is used in the Aviation runway light management system cyber range to simulate a tower operator's surveillance camera monitoring system to display four cameras shown below. The four cameras include :
Usage Case as Cyber Exercise Main Projection Screen
The system is used in to monitor all the UI program running on different VMs of the Land Based Railway IT-OT System Cyber Security Cyber Range System in the cyber exercise and project on the big TV as shown below. The 4 monitored program includes:
Thanks for spending time to check the article detail, if you have any question and suggestion or find any program bug, please feel free to message me. Many thanks if you can give some comments and share any of the improvement advice so we can make our work better ~
If you need the article translation to other language such as Chinese(Simple/Traditional), Thai, Vietnamese ... you can refer to this link : https://www.pixelstech.net/article/1762754941-python_virtual_motion-jpeg_camera_simulator?lang=chinese