Introduction
Oracle APEX provides a powerful low-code development environment for building interactive and database-driven applications. By integrating modern browser APIs with Oracle APEX, developers can extend application functionality beyond traditional forms and reports.
In this article, I will demonstrate how to build a Video Recording application in Oracle APEX that allows users to record videos directly through their browser, preview recordings, pause and resume recording, and save video files into an Oracle Database.
The solution combines JavaScript MediaRecorder API, browser camera and microphone access, FileReader API, Oracle APEX AJAX On-Demand Processes, PL/SQL, and BLOB storage.
1. Project Overview
The application provides a simple and interactive interface for recording and managing video clips.
Main Features:
-
Live camera preview before recording.
-
Start and stop video recording.
-
Pause and resume recording.
-
Recording duration timer.
-
Preview recorded video before saving.
-
Retry recording when required.
-
Enter a custom filename before saving.
-
Validate filename to prevent invalid characters.
-
Save video files directly into Oracle Database.
-
Store video metadata, duration, and application user information.
The application is designed to demonstrate how browser-based media functionality can be integrated with Oracle APEX.
2. Application Architecture
The solution uses three main layers:
Frontend β HTML, CSS and JavaScript
The frontend provides the video preview, recording controls, timer, playback interface, and filename dialog.
Browser APIs
The MediaDevices API accesses the camera and microphone, while the MediaRecorder API captures the video stream. The FileReader API converts the recorded Blob into Base64 data for transfer.
Backend β Oracle APEX and PL/SQL
An AJAX On-Demand Process receives the video data, converts Base64 content into a BLOB, and inserts the recording into the Oracle Database.
3. Application Page Structure
The exported application contains the following main recording page:
| Component | Description |
|---|---|
| Application Name | APP VIDEO RECORDING |
| Page Number | 2 |
| Page Name | VIDEO RECORD |
| AJAX Process | SAVE_VIDEO |
| Region | New |
| Recording Interface | Custom HTML and JavaScript |
The recording interface is implemented inside a custom region, allowing complete control over the recording workflow and user experience.
4. Creating the Video Recording Interface
The first step is to create the HTML interface inside a Static Content or suitable HTML region.
The interface contains two video elements:
-
A live preview element that displays the camera stream.
-
A playback element that displays the recorded video.
It also provides Start, Pause, Resume, Stop, Save, and Retry buttons.
HTML Code
<div id="recorderUI">
<div id="previewCard">
<label>Live Camera Preview</label>
<video id="preview" playsinline autoplay muted></video>
</div>
<div id="recordedCard" style="display:none;">
<label>Recorded Video</label>
<video id="playback" controls></video>
</div>
<div id="recordButtons">
<button id="btnStart" type="button">Start</button>
<button id="btnPause" type="button">Pause</button>
<button id="btnResume" type="button">Resume</button>
<button id="btnStop" type="button">Stop</button>
<span id="timer"></span>
</div>
<div id="postButtons" style="display:none;">
<button id="btnSave" type="button">Save</button>
<button id="btnRetry" type="button">Retry</button>
</div>
<div id="status"></div>
</div>
This interface provides the basic structure for the recording application. JavaScript controls the visibility and behavior of each section.
5. Accessing the Camera and Microphone
The browserβs MediaDevices API is used to request camera and microphone access.
The application uses getUserMedia() to obtain the media stream.
async function ensureCamera() {
mediaStream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: {
facingMode: 'user',
width: { ideal: 1280 },
height: { ideal: 720 }
}
});
preview.srcObject = mediaStream;
}
Once permission is granted, the live camera stream is displayed in the preview video element.
Important: Camera and microphone access generally requires HTTPS, except for supported localhost development environments. Users must also grant browser permissions.
6. Recording Video Using MediaRecorder API
The MediaRecorder API captures the audio and video stream and generates recorded data in chunks.
The application initializes the recorder using the browserβs supported video format.
const options = {
mimeType: 'video/webm;codecs=vp8,opus'
};
try {
mediaRecorder = new MediaRecorder(mediaStream, options);
} catch (e) {
mediaRecorder = new MediaRecorder(mediaStream);
}
The recorded video chunks are collected using the ondataavailable event.
mediaRecorder.ondataavailable = (event) => {
if (event.data && event.data.size > 0) {
chunks.push(event.data);
}
};
When recording stops, the collected chunks are combined into a single Blob.
const blob = new Blob(chunks, {
type: mediaRecorder.mimeType || 'video/webm'
});
This Blob represents the recorded video and is used for playback and database storage.
7. Implementing Pause, Resume and Stop
The application provides flexible recording controls.
Pause Recording
mediaRecorder.pause();
Resume Recording
mediaRecorder.resume();
Stop Recording
mediaRecorder.stop();
The application also maintains recording time and excludes paused time from the final duration calculation.
After stopping, the recorded video is assigned to the playback element:
playback.src = URL.createObjectURL(blob);
playback.load();
Users can review the recorded video before saving it.
8. Converting Video Blob into Base64
Before transferring the video to Oracle APEX, the recorded Blob is converted into Base64 using the FileReader API.
function blobToBase64(blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsDataURL(blob);
});
}
The Base64 payload is extracted from the Data URL and prepared for server-side processing.
const base64 = await blobToBase64(lastRecording.blob);
const payload = base64.split(',')[1];
9. Creating the Database Table
The application export references an existing table named VIDEO_CAPTURE. The following is a representative table structure based on the columns used by the exported SAVE_VIDEO process.
CREATE TABLE VIDEO_CAPTURE
(
VIDEO_ID NUMBER GENERATED BY DEFAULT AS IDENTITY
PRIMARY KEY,
FILENAME VARCHAR2(255),
MIME_TYPE VARCHAR2(100),
BLOB_CONTENT BLOB,
DURATION_MS NUMBER,
CREATED_BY VARCHAR2(255),
CREATED_ON DATE DEFAULT SYSDATE
);
The BLOB column stores the actual video content, while the remaining columns maintain recording information.
Note: The supplied page export references VIDEO_CAPTURE but does not include its original table DDL. This is a representative structure; confirm the existing table definition before executing it.
10. Creating the AJAX On-Demand Process
The application uses an AJAX On-Demand Process named:
SAVE_VIDEO
This process receives the video filename, MIME type, Base64 data, and recording duration from JavaScript.
Navigate to:
Page Designer β Processing β Processes
Create a new process with:
| Property | Value |
|---|---|
| Name | SAVE_VIDEO |
| Type | Execute Code |
| Language | PL/SQL |
| Execution Point | On Demand |
PL/SQL Code
DECLARE
l_blob BLOB;
l_filename VARCHAR2(255) := apex_application.g_x01;
l_mime VARCHAR2(100) := apex_application.g_x02;
l_b64 CLOB := apex_application.g_x03;
l_duration NUMBER := TO_NUMBER(apex_application.g_x04);
BEGIN
l_blob := apex_web_service.clobbase642blob(l_b64);
INSERT INTO video_capture
(
filename,
mime_type,
blob_content,
duration_ms,
created_by
)
VALUES
(
l_filename,
l_mime,
l_blob,
l_duration,
v('APP_USER')
);
apex_json.open_object;
apex_json.write('status', 'ok');
apex_json.close_object;
EXCEPTION
WHEN OTHERS THEN
apex_json.open_object;
apex_json.write('status', 'error');
apex_json.write('message', SQLERRM);
apex_json.close_object;
END;
The process converts Base64 data into a BLOB and inserts the recording into the VIDEO_CAPTURE table.
11. Sending Video Data to Oracle APEX
After the user enters a valid filename and confirms the save operation, JavaScript calls the SAVE_VIDEO AJAX process.
The application sends the required values through the apex.server.process API.
apex.server.process('SAVE_VIDEO', {
x01: displayName,
x02: lastRecording.mime,
x03: payload,
x04: String(lastRecording.durationMs),
x05: String(lastRecording.segments)
}, {
dataType: 'json',
success: function (data) {
if (data.status === 'ok') {
apex.message.showPageSuccess('Video saved successfully.');
} else {
apex.message.alert(data.message);
}
},
error: function () {
apex.message.alert('Video upload failed.');
}
});
The server-side process uses g_x01 through g_x04 for the values it currently stores. Although the JavaScript also sends g_x05 for the segment count, the exported PL/SQL process does not currently save that value.
12. Filename Validation
Before saving, the application displays a filename dialog.
Users can enter a custom filename, and JavaScript validates the input to allow only:
-
Letters
-
Numbers
-
Hyphens
-
Underscores
This helps maintain consistent filenames and avoids unsupported characters.
The application adds the .webm extension to the entered filename before uploading the recording.
13. Recording Workflow
The complete application workflow is:
flowchart TD
A[Open Oracle APEX Application] --> B[Request Camera and Microphone Access]
B --> C[Display Live Video Preview]
C --> D[Start Recording]
D --> E[Capture Video Using MediaRecorder]
E --> F{Recording Action}
F -->|Pause| G[Pause Recording]
G --> H[Resume Recording]
H --> E
F -->|Stop| I[Create Video Blob]
I --> J[Preview Recorded Video]
J --> K[Enter Filename]
K --> L[Convert Blob to Base64]
L --> M[Call SAVE_VIDEO AJAX Process]
M --> N[Convert Base64 to BLOB]
N --> O[Insert Video into Oracle Database]
O --> P[Display Success Message]
14. Important Technical Considerations
When implementing video recording in a production Oracle APEX application, consider the following:
-
Browser compatibility: Check MediaRecorder support and available MIME types before starting a recording.
-
HTTPS security: Camera and microphone access requires a secure browser context.
-
File size: Video files can become large, so define reasonable recording limits.
-
Upload limits: Review ORDS, proxy, web server, and database request-size limits.
-
Error handling: Handle camera permission failures, unsupported formats, and upload errors.
-
Database storage: Monitor BLOB storage growth and establish an appropriate retention policy.
-
Transaction management: Ensure unsuccessful uploads do not leave incomplete records.
-
Security: Apply authentication and authorization to recording and playback operations.
For larger video files, a chunked upload strategy or another suitable streaming approach may be more efficient than transferring the entire Base64 payload in one AJAX request.
15. Key Technical Highlights
This project demonstrates practical integration of several technologies:
| Technology | Purpose |
|---|---|
| Oracle APEX | Application development platform |
| HTML5 Video | Live preview and playback |
| JavaScript | Recording controls and workflow |
| MediaDevices API | Camera and microphone access |
| MediaRecorder API | Video recording |
| FileReader API | Blob to Base64 conversion |
| APEX AJAX Process | Asynchronous server communication |
| PL/SQL | Server-side processing |
| BLOB | Video file storage |
| Oracle Database | Persistent recording storage |
Conclusion
Building a Video Recording application in Oracle APEX demonstrates how modern browser capabilities can be combined with Oracle Database to create interactive and practical business solutions.
By integrating the MediaRecorder API, JavaScript, AJAX On-Demand Processes, PL/SQL, and BLOB storage, developers can capture video directly from the browser and persist recordings in the database.
This project provided an opportunity to explore browser-based media recording, asynchronous communication, binary data processing, and database integration within Oracle APEX.
I hope this article helps Oracle APEX developers understand how to implement video recording functionality and use modern web technologies to extend their applications.
Oracle ACE Associate Contribution
This article is shared as a technical knowledge contribution to the Oracle community, demonstrating practical Oracle APEX development techniques and integration with modern web technologies.
Oracle Solutions We believe in delivering tangible results for our customers in a cost-effective manner