Objective
Extract audio tracks from video files for independent processing. This enables transcription, audio analysis, multi-language dubbing, and accessibility features.
Step 1: Create Video Table
Create a table for videos with audio metadata.
CREATE TABLE videos_with_audio (
id INTEGER PRIMARY KEY,
title VARCHAR(255) NOT NULL,
video_file VIDEO(MP4),
duration_seconds INTEGER,
has_audio BOOLEAN DEFAULT TRUE,
audio_channels INTEGER DEFAULT 2,
audio_sample_rate INTEGER DEFAULT 48000,
audio_codec VARCHAR(50) DEFAULT 'AAC',
language VARCHAR(10) DEFAULT 'en',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Step 2: Create Extracted Audio Table
Create a table for extracted audio tracks.
CREATE TABLE extracted_audio (
id INTEGER PRIMARY KEY,
video_id INTEGER NOT NULL,
audio_file AUDIO(MP3),
audio_format VARCHAR(10) DEFAULT 'mp3',
track_type VARCHAR(50) DEFAULT 'main',
language VARCHAR(10),
bitrate INTEGER,
sample_rate INTEGER,
channels INTEGER,
duration_seconds INTEGER,
file_size BIGINT,
is_original BOOLEAN DEFAULT TRUE,
extraction_status VARCHAR(20) DEFAULT 'pending',
extracted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (video_id) REFERENCES videos_with_audio(id)
);
Step 3: Insert Sample Videos
Add sample video records.
INSERT INTO videos_with_audio (id, title, duration_seconds, has_audio, audio_channels, audio_sample_rate, audio_codec, language) VALUES
(1, 'Corporate Presentation', 1200, TRUE, 2, 48000, 'AAC', 'en'),
(2, 'Product Demo', 600, TRUE, 2, 44100, 'AAC', 'en'),
(3, 'Silent Animation', 120, FALSE, 0, 0, NULL, NULL),
(4, 'Interview Recording', 1800, TRUE, 1, 48000, 'AAC', 'en'),
(5, 'Music Video', 240, TRUE, 2, 48000, 'AAC', 'en'),
(6, 'Documentary Clip', 900, TRUE, 6, 48000, 'AC3', 'en'),
(7, 'Tutorial Series Ep1', 1500, TRUE, 2, 44100, 'AAC', 'es');
Step 4: Insert Extracted Audio
Add extracted audio track records.
INSERT INTO extracted_audio (id, video_id, audio_format, track_type, language, bitrate, sample_rate, channels, duration_seconds, file_size, is_original, extraction_status) VALUES
-- Video 1 audio tracks
(1, 1, 'mp3', 'main', 'en', 192000, 48000, 2, 1200, 28800000, TRUE, 'completed'),
(2, 1, 'wav', 'lossless', 'en', 1536000, 48000, 2, 1200, 230400000, TRUE, 'completed'),
-- Video 2 audio
(3, 2, 'mp3', 'main', 'en', 128000, 44100, 2, 600, 9600000, TRUE, 'completed'),
-- Video 4 audio (mono interview)
(4, 4, 'mp3', 'main', 'en', 96000, 48000, 1, 1800, 21600000, TRUE, 'completed'),
(5, 4, 'wav', 'lossless', 'en', 768000, 48000, 1, 1800, 172800000, TRUE, 'completed'),
-- Video 5 audio (music)
(6, 5, 'mp3', 'main', 'en', 320000, 48000, 2, 240, 9600000, TRUE, 'completed'),
(7, 5, 'flac', 'lossless', 'en', 1000000, 48000, 2, 240, 30000000, TRUE, 'completed'),
-- Video 6 audio (surround)
(8, 6, 'mp3', 'stereo_mixdown', 'en', 256000, 48000, 2, 900, 28800000, FALSE, 'completed'),
(9, 6, 'ac3', 'surround', 'en', 640000, 48000, 6, 900, 72000000, TRUE, 'completed'),
-- Video 7 audio (Spanish)
(10, 7, 'mp3', 'main', 'es', 192000, 44100, 2, 1500, 36000000, TRUE, 'completed');
Step 5: Query Videos with Audio
Get videos that have audio content.
SELECT
title,
duration_seconds / 60 as minutes,
audio_channels,
audio_sample_rate,
audio_codec,
language
FROM videos_with_audio
WHERE has_audio = TRUE
ORDER BY title;